Geant4 Cross Reference

Cross-Referencing   Geant4
Geant4/externals/g4tools/include/tools/hatcher.icc

Version: [ ReleaseNotes ] [ 1.0 ] [ 1.1 ] [ 2.0 ] [ 3.0 ] [ 3.1 ] [ 3.2 ] [ 4.0 ] [ 4.0.p1 ] [ 4.0.p2 ] [ 4.1 ] [ 4.1.p1 ] [ 5.0 ] [ 5.0.p1 ] [ 5.1 ] [ 5.1.p1 ] [ 5.2 ] [ 5.2.p1 ] [ 5.2.p2 ] [ 6.0 ] [ 6.0.p1 ] [ 6.1 ] [ 6.2 ] [ 6.2.p1 ] [ 6.2.p2 ] [ 7.0 ] [ 7.0.p1 ] [ 7.1 ] [ 7.1.p1 ] [ 8.0 ] [ 8.0.p1 ] [ 8.1 ] [ 8.1.p1 ] [ 8.1.p2 ] [ 8.2 ] [ 8.2.p1 ] [ 8.3 ] [ 8.3.p1 ] [ 8.3.p2 ] [ 9.0 ] [ 9.0.p1 ] [ 9.0.p2 ] [ 9.1 ] [ 9.1.p1 ] [ 9.1.p2 ] [ 9.1.p3 ] [ 9.2 ] [ 9.2.p1 ] [ 9.2.p2 ] [ 9.2.p3 ] [ 9.2.p4 ] [ 9.3 ] [ 9.3.p1 ] [ 9.3.p2 ] [ 9.4 ] [ 9.4.p1 ] [ 9.4.p2 ] [ 9.4.p3 ] [ 9.4.p4 ] [ 9.5 ] [ 9.5.p1 ] [ 9.5.p2 ] [ 9.6 ] [ 9.6.p1 ] [ 9.6.p2 ] [ 9.6.p3 ] [ 9.6.p4 ] [ 10.0 ] [ 10.0.p1 ] [ 10.0.p2 ] [ 10.0.p3 ] [ 10.0.p4 ] [ 10.1 ] [ 10.1.p1 ] [ 10.1.p2 ] [ 10.1.p3 ] [ 10.2 ] [ 10.2.p1 ] [ 10.2.p2 ] [ 10.2.p3 ] [ 10.3 ] [ 10.3.p1 ] [ 10.3.p2 ] [ 10.3.p3 ] [ 10.4 ] [ 10.4.p1 ] [ 10.4.p2 ] [ 10.4.p3 ] [ 10.5 ] [ 10.5.p1 ] [ 10.6 ] [ 10.6.p1 ] [ 10.6.p2 ] [ 10.6.p3 ] [ 10.7 ] [ 10.7.p1 ] [ 10.7.p2 ] [ 10.7.p3 ] [ 10.7.p4 ] [ 11.0 ] [ 11.0.p1 ] [ 11.0.p2 ] [ 11.0.p3, ] [ 11.0.p4 ] [ 11.1 ] [ 11.1.1 ] [ 11.1.2 ] [ 11.1.3 ] [ 11.2 ] [ 11.2.1 ] [ 11.2.2 ] [ 11.3.0 ]

Diff markup

Differences between /externals/g4tools/include/tools/hatcher.icc (Version 11.3.0) and /externals/g4tools/include/tools/hatcher.icc (Version 8.0.p1)


  1 //  Created by Laurent Garnier on Fri Jan 30 2      1 
  2                                                   
  3 //#define TOOLS_HATCHER_DEBUG                     
  4                                                   
  5 #ifdef TOOLS_HATCHER_DEBUG                        
  6 #include <cstdio>                                 
  7 #endif                                            
  8                                                   
  9 namespace tools {                                 
 10                                                   
 11 //////////////////////////////////////////////    
 12 // test if the polygone given is correct for h    
 13 // return FALSE if :                              
 14 //    - All points are not in the same plan       
 15 //    - Number of points <3                       
 16 //    - Offset point is not in the same plan      
 17 //    - There is less than three different poi    
 18 //    - The vector from point[0],point[1] is c    
 19 //////////////////////////////////////////////    
 20                                                   
 21 inline bool hatcher::check_polyline(vec3f* lis    
 22                                                   
 23   unsigned int firstOffset =0;                    
 24                                                   
 25   if ( listPoints[0].equals(listPoints[1],FLT_    
 26     firstOffset =1;                               
 27   }                                               
 28                                                   
 29   if ( listPoints[0].equals(listPoints[aNumber    
 30     aNumber --;                                   
 31   }                                               
 32                                                   
 33   if ((int)aNumber-firstOffset <3) {              
 34 #ifdef TOOLS_HATCHER_DEBUG                        
 35     ::printf("hatcher::check_polyline : ERROR     
 36 #endif                                            
 37     return false;                                 
 38   }                                               
 39                                                   
 40                                                   
 41   // use to test the polyline and to build the    
 42   // B second and C the last (in fact, the las    
 43   vec3f AB,AC;                                    
 44   AB.setValue(listPoints[1+firstOffset].getVal    
 45               listPoints[1+firstOffset].getVal    
 46               listPoints[1+firstOffset].getVal    
 47                                                   
 48                                                   
 49   fResolveResult = RESOLVE_COLINEAR;              
 50   unsigned int test = aNumber;                    
 51   while ((fResolveResult !=0) && (test>2+first    
 52     test--;                                       
 53     AC.setValue(listPoints[test].getValue()[0]    
 54                 listPoints[test].getValue()[1]    
 55                 listPoints[test].getValue()[2]    
 56                                                   
 57     // test if AB != AC*i                         
 58     resolve_system( AB,                           
 59                    AC,                            
 60                    vec3f(.0f,.0f,.0f));           
 61   }                                               
 62   if (fResolveResult == RESOLVE_COLINEAR) {       
 63 #ifdef TOOLS_HATCHER_DEBUG                        
 64     ::printf("hatcher::check_polyline : ERROR     
 65     for (unsigned int a =0;a<aNumber;a++) {       
 66       printf(" %f %f %f \n",listPoints[a][0],l    
 67 #endif                                            
 68     return false;                                 
 69   }                                               
 70                                                   
 71   ////////////////////////////////////////////    
 72   // test if all points of the polyline are on    
 73   ////////////////////////////////////////////    
 74                                                   
 75   int falsePoints =0;                             
 76   for (unsigned int a=2+firstOffset;a<aNumber;    
 77     resolve_system( AB,                           
 78                    AC,                            
 79                        vec3f((listPoints[a].ge    
 80                                (listPoints[a].    
 81                                (listPoints[a].    
 82     if (fResolveResult != 0){                     
 83       falsePoints++;                              
 84     }                                             
 85   }                                               
 86                                                   
 87   if (falsePoints !=0) {                          
 88 #ifdef TOOLS_HATCHER_DEBUG                        
 89     ::printf("hatcher::check_polyline : ERROR     
 90 #endif                                            
 91     return false;                                 
 92   }                                               
 93                                                   
 94   // test offset                                  
 95     if (! ((fOffset[0] == FLT_MAX) && (fOffset    
 96       resolve_system( AB,                         
 97                      AC,                          
 98                      fOffset-listPoints[0]);      
 99       if (fResolveResult != 0) {                  
100 #ifdef TOOLS_HATCHER_DEBUG                        
101         ::printf("hatcher::check_polyline : ER    
102 #endif                                            
103         return false;                             
104       }                                           
105     }                                             
106     return true;                                  
107 }                                                 
108                                                   
109                                                   
110 //////////////////////////////////////////////    
111 // draw the hatch into the polyline bounding b    
112 // return false if :                              
113 //    - All points are not in the same plan       
114 //    - There is a precision error on one or m    
115 // Compute a first sequence of hacth, store re    
116 // and match all results to get the correct st    
117 //////////////////////////////////////////////    
118 /** Compute stripWidth                            
119  * We have to use the conflictNumHatchLineTab,    
120  * also the HatchShiftToMacthPoint tab.           
121  * and the hatch line just compute below          
122  * We try to made a polyline with all points w    
123  * (distant of stripwidth form current hatch)     
124  * conflictNumHatchLineTab give us something l    
125  * current   next                                 
126  *    4       4              if we consider th    
127  *    0       5              we know the compu    
128  *    1       3              lines, we could l    
129  *    3       2              some of theses li    
130  *    5                        so ->>             
131  *    2                                           
132  *  And we have to add some points when  Hatch    
133  * and next hatch :  We add a point B on inter    
134  * current   next                                 
135  *    ,4             ,4                           
136  *    '0    B(0,1)   '5                           
137  *    ,1                                          
138  *    '3             ,3                           
139  *    ,5             '2                           
140  *    '2                                          
141  *                                                
142  * Now we have to match a way to traverse all     
143  * one line to another :                          
144  * - go to the next point if there is one betw    
145  * - go to the same line but on another hatch     
146  * - go to the next tach point                    
147  * If there is no solution, we have to close t    
148  * all are compute                                
149  */                                               
150                                                   
151 /** first, we have to match 7 different cases     
152  * 1- all strip hatch are entirely in the poly    
153  * 2- the first strip begin before the polylin    
154  * 3- the first strip begin before the polylin    
155  * 4- the first strip is entierly in the polyl    
156  * 5- the strip has only an intersection with     
157  *    with the first hatch sequence, it is cas    
158  * 6- the strip has a full intersection           
159  * 7- the strip has no intersection !             
160  */                                               
161                                                   
162 inline bool hatcher::compute_polyline (vec3f*     
163   std::vector<vec3f> firstComputePoints;   //     
164   std::vector<vec3f> secondComputePoints;   //    
165   std::vector<bool> firstComputePointsEnable;     
166   std::vector<bool> secondComputePointsEnable;    
167   std::vector< std::vector<int> > firstCompute    
168                                                   
169   int firstComputeFirstNumHatch =0;               
170   unsigned int firstComputeNumberHatchToDraw =    
171   float firstHatchShiftToMatchFirstPoint = FLT    
172   float secondHatchShiftToMatchFirstPoint = FL    
173   //call compute for first set of hatch           
174   if ( !compute_single_polyline (tabPoints,aNu    
175     return false;                                 
176   if (fStripWidth ==0)                            
177     return true;                                  
178                                                   
179                                                   
180   //save values                                   
181   for (unsigned int a =0;a<fPoints.size();a++)    
182     firstComputePoints.push_back(fPoints[a]);     
183   }                                               
184                                                   
185   firstComputeConflictNumHatchLineTab.resize(f    
186   for (unsigned int a=0;a<fConflictNumHatchLin    
187     firstComputeConflictNumHatchLineTab[a].cle    
188     for (unsigned int b=0;b<fConflictNumHatchL    
189       firstComputeConflictNumHatchLineTab[a].p    
190     }                                             
191   }                                               
192   firstComputeFirstNumHatch = fFirstNumHatch;     
193   firstComputeNumberHatchToDraw = fNumberHatch    
194   firstHatchShiftToMatchFirstPoint = fHatchShi    
195   //change the offset vector                      
196   fOffset = fOffset+fShiftVec*fStripWidth;        
197                                                   
198   //call compute for second set of hatch          
199   if ( !compute_single_polyline (tabPoints,aNu    
200     return false;                                 
201                                                   
202   //save values                                   
203   for (unsigned int a =0;a<fPoints.size();a++)    
204     secondComputePoints.push_back(fPoints[a]);    
205   }                                               
206                                                   
207   secondHatchShiftToMatchFirstPoint = fHatchSh    
208                                                   
209                                                   
210   // initialize values                            
211   fPoints.clear();                                
212   fVertices.clear();                              
213                                                   
214   int specialCase=1;                              
215                                                   
216   //first hatch, case 1                           
217   if ((firstComputeFirstNumHatch == fFirstNumH    
218     specialCase =1;                               
219   }                                               
220   //first hatch, case 2                           
221   else if ((firstComputeFirstNumHatch > fFirst    
222     //insert a empty element at the beginning     
223     firstComputeConflictNumHatchLineTab.insert    
224     firstComputeConflictNumHatchLineTab[0].res    
225     firstComputeFirstNumHatch--;                  
226     firstComputeNumberHatchToDraw ++;             
227     firstComputeConflictNumHatchLineTab[0].cle    
228     specialCase =2;                               
229                                                   
230   }   //second hatch, case 3                      
231   else   if (((firstComputeFirstNumHatch > fFi    
232     //insert a empty element at the beginning     
233     firstComputeConflictNumHatchLineTab.insert    
234     firstComputeConflictNumHatchLineTab[0].res    
235     firstComputeConflictNumHatchLineTab[0].cle    
236     //insert a empty element at the end           
237     fConflictNumHatchLineTab.push_back(firstCo    
238     fConflictNumHatchLineTab.back().resize(0);    
239     fConflictNumHatchLineTab.back().clear();      
240     firstComputeFirstNumHatch--;                  
241     firstComputeNumberHatchToDraw ++;             
242     specialCase =3;                               
243   }   //second hatch, case 4                      
244   else   if (((firstComputeFirstNumHatch == fF    
245     //insert a empty element at the end           
246     fConflictNumHatchLineTab.push_back(firstCo    
247     fConflictNumHatchLineTab.back().resize(0);    
248     fConflictNumHatchLineTab.back().clear();      
249     specialCase =4;                               
250                                                   
251   }   //second hatch, case 5                      
252   else   if ((firstComputeNumberHatchToDraw ==    
253     //insert a empty element at the beginning     
254     firstComputeConflictNumHatchLineTab.insert    
255     firstComputeConflictNumHatchLineTab[0].res    
256     firstComputeConflictNumHatchLineTab[0].cle    
257     firstComputeNumberHatchToDraw ++;             
258     specialCase =5;                               
259                                                   
260   }   //second hatch, case 6                      
261   else if (floorf(firstHatchShiftToMatchFirstP    
262     specialCase =6;                               
263                                                   
264     //fill all the polygone !                     
265     fVertices.push_back(aNumber);                 
266     for (unsigned int a =0;a<aNumber;a++){        
267       fPoints.push_back(tabPoints[a]);            
268     }                                             
269     return true;                                  
270   }                                               
271   else if (floorf(firstHatchShiftToMatchFirstP    
272     specialCase =7;                               
273     return true;                                  
274   } else {                                        
275 #ifdef TOOLS_HATCHER_DEBUG                        
276     ::printf("hatcher::drawStripPolyline : WAR    
277 #endif                                            
278                                                   
279   }                                               
280                                                   
281                                                   
282   bool result;                                    
283   bool find; // temp variable                     
284   int firstHatchComputePoint = 0; //first poin    
285   int secondHatchComputePoint = 0; //first poi    
286   unsigned int lineNumber;                        
287   unsigned int firstPointTabInd =0;               
288   unsigned int secondPointTabInd=0;               
289   unsigned int currentHatch; // 0 is first, 1     
290   unsigned int solution; //default for beginni    
291   unsigned int indTmp;                            
292   unsigned int oldSolution;                       
293   for (unsigned int indHatch =0;indHatch<first    
294                                                   
295                                                   
296     currentHatch =0; // 0 is first, 1 is secon    
297     solution =99; //default for beginning         
298     indTmp = 0;                                   
299     lineNumber = 0;                               
300     secondComputePointsEnable.clear();            
301     firstComputePointsEnable.clear();             
302     for (unsigned int a=0;a<firstComputeConfli    
303       firstComputePointsEnable.push_back(false    
304     for (unsigned int a=0;a<fConflictNumHatchL    
305       secondComputePointsEnable.push_back(fals    
306                                                   
307     if ((indHatch == 0) && ((specialCase ==2)     
308       for (unsigned int a=0;a<firstComputeConf    
309         firstComputePointsEnable[a] = true;       
310       }                                           
311     }                                             
312     if ((indHatch == (firstComputeNumberHatchT    
313       for (unsigned int a=0;a<fConflictNumHatc    
314         secondComputePointsEnable[a] = true;      
315       }                                           
316     }                                             
317                                                   
318     result = false;                               
319     while (result == false) {                     
320                                                   
321                                                   
322       //find a uncompute point for this set of    
323       result =true;                               
324       unsigned int b=0;                           
325       while ((result == true) && (b<firstCompu    
326         if (firstComputePointsEnable[b] == fal    
327           result =false;                          
328           firstHatchComputePoint = b;             
329           lineNumber = firstComputeConflictNum    
330           fPoints.push_back(firstComputePoints    
331           fVertices.push_back(1);                 
332           firstComputePointsEnable[b] = true;     
333           currentHatch = 0;                       
334         }                                         
335         b++;                                      
336       }                                           
337       if (result ==true) {                        
338         //find a uncompute point for this set     
339                                                   
340         while ((result == true) && (b<fConflic    
341           if (secondComputePointsEnable[b] ==     
342             result =false;                        
343             secondHatchComputePoint = b;          
344             lineNumber = fConflictNumHatchLine    
345             fPoints.push_back(secondComputePoi    
346             fVertices.push_back(1);               
347             secondComputePointsEnable[b] = tru    
348             currentHatch = 1;                     
349           }                                       
350           b++;                                    
351         }                                         
352       }                                           
353       if (result == true) {                       
354       }                                           
355         solution =99; // to enter in the while    
356         while (solution !=0) {                    
357           oldSolution = solution;                 
358           solution =0; //default                  
359           // get the line number for this poin    
360           /** Now we have to match a way to tr    
361            * one line to another :                
362            * - go to the next point if there i    
363            * - go to the same line but on anot    
364            * - go to the next hatch point         
365            */                                     
366           if (currentHatch != 1) {                
367                                                   
368             if (oldSolution != 3) {               
369               int index =0;                       
370               if ((firstHatchComputePoint % 2     
371               else if ((firstHatchComputePoint    
372               if (index !=0) {                    
373                 solution = 1;                     
374                 oldSolution = 0;                  
375                 firstHatchComputePoint = first    
376                 fPoints.push_back(firstCompute    
377                 fVertices.back() ++;              
378                 firstComputePointsEnable[first    
379                 lineNumber = firstComputeConfl    
380               }                                   
381             }                                     
382             if (solution == 0) {                  
383               indTmp = 0;                         
384               while ((solution == 0) && (indTm    
385                 if ((fConflictNumHatchLineTab[    
386                   solution =2;                    
387                   oldSolution = 0;                
388                   fPoints.push_back(secondComp    
389                   fVertices.back() ++;            
390                   secondComputePointsEnable[in    
391                   lineNumber = fConflictNumHat    
392                   secondHatchComputePoint = in    
393                   currentHatch =1;                
394                 }                                 
395                 indTmp ++;                        
396               }                                   
397             }                                     
398             if (solution == 0) {                  
399               indTmp = 0;                         
400               while ((solution == 0) && (indTm    
401                                                   
402                 if ((fHatchShiftToMatchPointVe    
403                     && (fHatchShiftToMatchPoin    
404                     && ((indTmp == lineNumber)    
405                   find = false;                   
406                   unsigned a =0;                  
407                   while ((a<fVertices.back())     
408                     if ((tabPoints[indTmp][0]     
409                     a++;                          
410                   }                               
411                   if (find == false){             
412                     solution = 3;                 
413                     oldSolution = 0;              
414                     currentHatch =2;              
415                     fPoints.push_back(tabPoint    
416                     fVertices.back() ++;          
417                     if (lineNumber == indTmp)     
418                       if (indTmp >0)  lineNumb    
419                       else lineNumber = aNumbe    
420                     }                             
421                     else {                        
422                       if (indTmp < aNumber-1)     
423                       else lineNumber = 0;        
424                     }                             
425                   }                               
426                 }                                 
427                 indTmp++;                         
428               }                                   
429             }                                     
430           } // end of current hatch               
431                                                   
432             //test of second hatch if currentH    
433           if ((oldSolution != 0) && (solution     
434                                                   
435             if (oldSolution != 3){                
436               int index =0;                       
437               if ((secondHatchComputePoint % 2    
438               else if ((secondHatchComputePoin    
439               if (index !=0){                     
440                 solution = 1;                     
441                 secondHatchComputePoint = seco    
442                 fPoints.push_back(secondComput    
443                 fVertices.back() ++;              
444                 secondComputePointsEnable[seco    
445                 lineNumber = fConflictNumHatch    
446               }                                   
447             }                                     
448             if (solution == 0) {                  
449               indTmp = 0;                         
450               while ((solution == 0) && (indTm    
451                 if ((firstComputeConflictNumHa    
452                   solution =2;                    
453                   fPoints.push_back(firstCompu    
454                   fVertices.back() ++;            
455                   firstComputePointsEnable[ind    
456                   lineNumber = firstComputeCon    
457                   firstHatchComputePoint = ind    
458                   currentHatch =0;                
459                 }                                 
460                 indTmp ++;                        
461               }                                   
462             }                                     
463             if (solution == 0) {                  
464               indTmp = 0;                         
465               while ((solution == 0) && (indTm    
466                                                   
467                 if ((fHatchShiftToMatchPointVe    
468                     && (fHatchShiftToMatchPoin    
469                     && ((indTmp == lineNumber)    
470                   find = false;                   
471                   unsigned a =0;                  
472                   while ((a<fVertices.back())     
473                     if ((tabPoints[indTmp][0]     
474                     a++;                          
475                   }                               
476                   if (find == false){             
477                     currentHatch =2;              
478                     solution = 3;                 
479                     fPoints.push_back(tabPoint    
480                     fVertices.back() ++;          
481                     if (lineNumber == indTmp)     
482                       if (indTmp >0)  lineNumb    
483                       else lineNumber = aNumbe    
484                     }                             
485                     else {                        
486                       if (indTmp < aNumber-1)     
487                       else lineNumber = 0;        
488                     }                             
489                   }                               
490                 }                                 
491                 indTmp++;                         
492               }                                   
493             }                                     
494           } // end of current hatch               
495           if (solution == 0) {                    
496             // the end for this polyline          
497             // close polyline                     
498             fPoints.push_back(fPoints[fPoints.    
499             fVertices.back() ++;                  
500             result =true;                         
501           }                                       
502         } // while solution !=0                   
503         //      } // if result                    
504     } // while result                             
505     for (unsigned int a =0;a<fVertices.size();    
506 #ifdef TOOLS_HATCHER_DEBUG                        
507       if (fVertices[a] <4) ::printf("hatcher::    
508 #endif                                            
509     }                                             
510                                                   
511     firstPointTabInd += firstComputeConflictNu    
512     secondPointTabInd += fConflictNumHatchLine    
513   } //end for                                     
514   return true;                                    
515 }                                                 
516                                                   
517                                                   
518                                                   
519                                                   
520 //////////////////////////////////////////////    
521 // draw the hatch into the polyline bounding b    
522 // return false if :                              
523 //    - All points are not in the same plan       
524 //    - There is a precision error on one or m    
525 //////////////////////////////////////////////    
526                                                   
527 inline bool hatcher::compute_single_polyline (    
528   std::vector<vec3f> listNormalVec;               
529   int numberOfPolylinePoints =0;                  
530   fPoints.resize(0);                              
531   fPoints.clear();                                
532   int precisionError =0;                          
533   unsigned int firstOffset =0;                    
534   fFirstNumHatch =0;                              
535   fNumberHatchToDraw =0;                          
536   fVertices.resize(0);                            
537   fVertices.clear();                              
538                                                   
539   if ( tabPoints[0].equals(tabPoints[1].getVal    
540     firstOffset =1;  }                            
541                                                   
542   vec3f* listPoints = new vec3f[aNumber+1-firs    
543                                                   
544   for (unsigned int i=0;i<aNumber;i++){           
545     if ((i==0) || (listPoints[i-1] !=tabPoints    
546       listPoints[numberOfPolylinePoints] = tab    
547       numberOfPolylinePoints++;                   
548     }                                             
549   }                                               
550                                                   
551   // add the first point on last position to c    
552   if ( ! listPoints[0].equals(listPoints[numbe    
553     listPoints[numberOfPolylinePoints]=listPoi    
554     numberOfPolylinePoints ++;                    
555   }                                               
556                                                   
557   // use to test the polyline and to build the    
558   // B second and C the last (in fact, the las    
559   vec3f AB,AC;                                    
560   AB.setValue(listPoints[1].getValue()[0]-list    
561               listPoints[1].getValue()[1]-list    
562               listPoints[1].getValue()[2]-list    
563                                                   
564   fResolveResult = RESOLVE_COLINEAR;              
565   unsigned int test = numberOfPolylinePoints-1    
566   while ((fResolveResult !=0) && (test>1)) {      
567     test--;                                       
568     AC.setValue(listPoints[test].getValue()[0]    
569                 listPoints[test].getValue()[1]    
570                 listPoints[test].getValue()[2]    
571                                                   
572     // test if AB != AC*i                         
573     resolve_system( AB,                           
574                    AC,                            
575                    vec3f(.0f,.0f,.0f));           
576   }                                               
577   if (fResolveResult == RESOLVE_COLINEAR) {       
578 #ifdef TOOLS_HATCHER_DEBUG                        
579     ::printf("hatcher::drawPolyline : ERROR al    
580     for (unsigned int a =0;a<aNumber;a++) {       
581       printf(" %f %f %f \n",listPoints[a][0],l    
582 #endif                                            
583     delete [] listPoints;                         
584     return false;                                 
585   }                                               
586                                                   
587   ////////////////////////////////////////////    
588   // creation of the dirVec. It is done with t    
589   // The angle is the one between the first li    
590   // and the dirVec, on the plan delimited by     
591   // Given in the direct axis ((point1-point0)    
592   // Normal plane Vector = AB x AC                
593   ////////////////////////////////////////////    
594   if (fFirstPolyline) {                           
595                                                   
596     fFirstPolyline = false;                       
597                                                   
598     fNormal.setValue(AB[1]*AC[2]-AB[2]*AC[1],     
599                                AB[2]*AC[0]-AB[    
600                                AB[0]*AC[1]-AB[    
601                                                   
602                                                   
603     // ABPerp Vector = normal x AB                
604     vec3f ABPerpVector;                           
605     ABPerpVector.setValue(fNormal[1]*AB[2]-fNo    
606                           fNormal[2]*AB[0]-fNo    
607                           fNormal[0]*AB[1]-fNo    
608                                                   
609     float normAB =(float)std::sqrt(std::pow(AB    
610                         std::pow(AB[1],2)+        
611                         std::pow(AB[2],2));       
612     float normABPerpVector =(float)std::sqrt(s    
613                         std::pow(ABPerpVector[    
614                         std::pow(ABPerpVector[    
615                                                   
616     float j = std::tan(fDirAngle)*normAB/normA    
617                                                   
618     if (normABPerpVector == 0){  // never done    
619 #ifdef TOOLS_HATCHER_DEBUG                        
620       ::printf("hatcher::drawPolyline : ERROR     
621 #endif                                            
622       delete [] listPoints;                       
623       return false;                               
624     }                                             
625                                                   
626     fDirVec = AB +(float)j*ABPerpVector;          
627     // normalize vector to unit on X or on Y      
628     if (fDirVec.getValue()[0] ==0){               
629       fDirVec[0] = fPrecisionFactor; // to get    
630       fDirVec = fDirVec/fDirVec.getValue()[1];    
631     } else {                                      
632       fDirVec = fDirVec/fDirVec.getValue()[0];    
633     }                                             
634                                                   
635     //////////////////////////////////////////    
636     // creation of the shiftVec thanks to the     
637     //////////////////////////////////////////    
638                                                   
639     vec3f dirShiftVector;                         
640     dirShiftVector.setValue(fNormal[1]*fDirVec    
641                             fNormal[2]*fDirVec    
642                             fNormal[0]*fDirVec    
643                                                   
644     // normalize vector to match the shift siz    
645     float param = 1.0f;                           
646     param = (float)std::sqrt((std::pow(fShift,    
647                                         std::p    
648                                         std::p    
649                                         std::p    
650     fShiftVec = dirShiftVector*param;             
651                                                   
652     // compute offset only if it was not given    
653     if ((fOffset[0] == FLT_MAX) && (fOffset[1]    
654       fOffset = listPoints[0]+fShiftVec*fOffse    
655     }                                             
656   }                                               
657                                                   
658                                                   
659   ////////////////////////////////////////////    
660   // START to compute                             
661   // We compute each line one by one to know w    
662   // we try to know the result of                 
663   // (origin_point_of_hatch)+i*(directionVecto    
664   // We will be interest only on j factor for     
665   // between the Origin point of the hatch and    
666   // We put results in a float table              
667   //                                              
668   // We also have to memorize the min and max     
669   // Point                  0 1 2 3 4 5 6 ...n    
670   // hatchShiftToMatchPoint   5 7 2 6 7 8 5 ..    
671   // min = 1 max = 8   -> 8 hatch to draw         
672   ////////////////////////////////////////////    
673                                                   
674   fHatchShiftToMatchPointVec.resize(numberOfPo    
675   float minShiftHatch =FLT_MAX;                   
676   float maxShiftHatch =-FLT_MAX;                  
677   vec2f res;                                      
678                                                   
679   for (int a=0;a<numberOfPolylinePoints;a++) {    
680     res = resolve_system(fDirVec.getValue(),      
681                         fShiftVec,                
682                         listPoints[a]-fOffset)    
683     // test result                                
684     if (fResolveResult ==0 ) {                    
685          fHatchShiftToMatchPointVec[a] = res[1    
686          if (res[1]>maxShiftHatch) {              
687            maxShiftHatch = res[1];                
688          }                                        
689          if (res[1]<minShiftHatch) {              
690            minShiftHatch = res[1];                
691          }                                        
692     }                                             
693     else {  // never done (should be test befo    
694 #ifdef TOOLS_HATCHER_DEBUG                        
695       ::printf("hatcher::drawPolyline : ERROR     
696 #endif                                            
697       delete [] listPoints;                       
698       return false;                               
699     }                                             
700   }                                               
701   // for the first point to close the polyline    
702   fHatchShiftToMatchPointVec[numberOfPolylineP    
703   fFirstNumHatch = (int)(ceilf(minShiftHatch))    
704   fNumberHatchToDraw = (int)(floorf(maxShiftHa    
705   if ((int)(floorf(maxShiftHatch)-fFirstNumHat    
706                                                   
707   int moreNumberHatchToDraw = fNumberHatchToDr    
708   std::vector<vec3f> listHatchStartPoint;         
709   std::vector<vec3f> listHatchEndPoint;           
710   std::vector<int> numberOfStartEndPointsVec;     
711                                                   
712   fConflictNumHatchLineTab.resize(moreNumberHa    
713                                                   
714   // initialize tab                               
715     for (int a=0;a<moreNumberHatchToDraw;a++)     
716       numberOfStartEndPointsVec.push_back(0);     
717       listHatchStartPoint.push_back(vec3f(.0f,    
718       listHatchEndPoint.push_back(vec3f(.0f,.0    
719       fConflictNumHatchLineTab[a].clear();        
720     }                                             
721                                                   
722   ////////////////////////////////////////////    
723   // Compute the normalize shift vector for al    
724   // the normal Vector for point 3 to 4 will b    
725   ////////////////////////////////////////////    
726                                                   
727   for (int a=0;a<numberOfPolylinePoints-1;a++)    
728     res = resolve_system(fDirVec.getValue(),      
729                         vec3f(listPoints[a].ge    
730                                 listPoints[a].    
731                                 listPoints[a].    
732                         -fShiftVec);              
733     if (fResolveResult ==0 ) {                    
734       listNormalVec.push_back(vec3f(res[1]*(li    
735                                        res[1]*    
736                                        res[1]*    
737                                        ));        
738     }                                             
739     else  if (fResolveResult == RESOLVE_Z_ERRO    
740 #ifdef TOOLS_HATCHER_DEBUG                        
741       ::printf("hatcher::drawPolyline : ERROR     
742 #endif                                            
743       delete [] listPoints;                       
744       return false;                               
745     }                                             
746     else{                                         
747       listNormalVec.push_back(vec3f(FLT_MAX,FL    
748       //      listNormalVec.append(new vec3f(F    
749     }                                             
750  }                                                
751                                                   
752   ////////////////////////////////////////////    
753   // Compute the hatchShiftToMatchPointVec tab    
754   // and end point of each hatch                  
755   // if there is more than one start/end point    
756   // we put confict points into a table           
757   // HatchNumber        1     2     3      4      
758   // listHatchStartPoint  1,0,0  1,1,0  0,0,1     
759   // listHatchEndPoint    ..............          
760   // conflictNumHatchLineTab 5 6 7                
761   // line Number is 0 for (point[0]->point[1])    
762   // We put each line number into the conflict    
763   //  in conflict. When we will thest the valu    
764   // be greater than 2 to have a conflict         
765   ////////////////////////////////////////////    
766                                                   
767   vec3f newPoint;                                 
768   int minHatch;                                   
769   int maxHatch;                                   
770   int hatchIndice =0;                             
771                                                   
772   for (int indPolyline=0;indPolyline<numberOfP    
773     minHatch = (int)(ceilf(fHatchShiftToMatchP    
774     maxHatch = (int)(floorf(fHatchShiftToMatch    
775                                                   
776     if (fHatchShiftToMatchPointVec[indPolyline    
777       minHatch =(int)(ceilf(fHatchShiftToMatch    
778       maxHatch = (int)(floorf(fHatchShiftToMat    
779     }                                             
780     for (int b=minHatch;b<=maxHatch;b++) {  //    
781       // compute new point                        
782       hatchIndice = b-fFirstNumHatch;             
783                                                   
784       newPoint.setValue(listPoints[indPolyline    
785                         listNormalVec[indPolyl    
786                         listPoints[indPolyline    
787                         listNormalVec[indPolyl    
788                         listPoints[indPolyline    
789                         listNormalVec[indPolyl    
790                                                   
791       if (numberOfStartEndPointsVec[hatchIndic    
792         //compute point and save it               
793         // the start point will be :              
794         // Point_of_the_line + normalVec *        
795         //(number_of_hatch_to_compute - number    
796         //                                        
797         if ( (listNormalVec[indPolyline][0] !=    
798             && (listNormalVec[indPolyline][1]     
799             && (listNormalVec[indPolyline][2]     
800           listHatchStartPoint[hatchIndice] = v    
801            fConflictNumHatchLineTab[hatchIndic    
802            numberOfStartEndPointsVec[hatchIndi    
803          }                                        
804       } else if (numberOfStartEndPointsVec[hat    
805         //compute point and save it (same poin    
806         // the start point will be :              
807         // Point_of_the_line + normalVec *        
808         //  (number_of_hatch_to_compute - numb    
809         // store only if newPoint is != start     
810         if ((listNormalVec[indPolyline][0] !=     
811             && (listNormalVec[indPolyline][1]     
812             && (listNormalVec[indPolyline][2]     
813           listHatchEndPoint[hatchIndice] = vec    
814           fConflictNumHatchLineTab[hatchIndice    
815           numberOfStartEndPointsVec[hatchIndic    
816         }                                         
817       } else { // there is a conflict, we don'    
818         // witch are already compute              
819         // case of the hatch will be draw on a    
820         // so it match 2 lines + another          
821         fConflictNumHatchLineTab[hatchIndice].    
822       }                                           
823     }                                             
824   }                                               
825                                                   
826   ////////////////////////////////////////////    
827   // Compute the numHatchLine tab and draw cor    
828   ////////////////////////////////////////////    
829   std::vector<float> listCoefDirHatch(fNumberH    
830   std::vector<vec3f> listConflictPoints(number    
831                                                   
832   vec3f ABVec,tempVec;                            
833   int valid =false;                               
834   bool drawEnabled = false; // true : we could    
835   float temp=0;                                   
836   int tempInt =0;                                 
837   float nextPointConflictHatchNumber = -FLT_MA    
838   float currentPointConflictHatchNumber = -FLT    
839   std::vector<unsigned int> orderConflictLineN    
840                                                   
841   for (unsigned int hatchNumber =0;hatchNumber    
842     if ( fConflictNumHatchLineTab[hatchNumber]    
843       if (!listHatchStartPoint[hatchNumber].eq    
844         fPoints.push_back(listHatchStartPoint[    
845         fPoints.push_back(listHatchEndPoint[ha    
846         fVertices.push_back(2);                   
847       }                                           
848     } else { // there is a conflict               
849       // We read the conflict table and comput    
850       // conflict is on hatch number hatchNumb    
851       // Compute the equation on the conflict     
852       // i*dirVec - j*ABVec = A-(offset + shif    
853       // and store the i parameter                
854       // then we                                  
855                                                   
856       listConflictPoints.clear();                 
857       listCoefDirHatch.clear();                   
858       std::vector <unsigned int> toRemove;        
859       for (unsigned int conflictLineNumber=0;c    
860         {                                         
861                                                   
862           ABVec.setValue(listPoints[fConflictN    
863                          listPoints[fConflictN    
864                          listPoints[fConflictN    
865                                                   
866           res = resolve_system(fDirVec.getValu    
867                               ABVec,              
868                               vec3f(listPoints    
869                                       listPoin    
870                                       listPoin    
871                                                   
872           if (fResolveResult ==0 ) {              
873             // we store results                   
874             listCoefDirHatch.push_back(2);        
875             listCoefDirHatch.pop_back();          
876             listCoefDirHatch.push_back(res[0])    
877             res[1] = -res[1];                     
878             listConflictPoints.push_back(vec3f    
879           }                                       
880           else if (fResolveResult != RESOLVE_C    
881 #ifdef TOOLS_HATCHER_DEBUG                        
882             printf("hatcher : Precision error     
883 #endif                                            
884             precisionError++;                     
885           } else {                                
886             toRemove.push_back(conflictLineNum    
887           }                                       
888         }                                         
889                                                   
890       if (toRemove.size()) {                      
891         for (unsigned int conflictLineNumber=0    
892         }                                         
893         // remove potential colinear problems     
894         for (unsigned int aa=0;aa<toRemove.siz    
895           unsigned int ind = 0;                   
896           for (std::vector<int>::iterator it =    
897             if (ind == toRemove[aa]) {            
898               fConflictNumHatchLineTab[hatchNu    
899               break;                              
900             }                                     
901             ind++;                                
902           }                                       
903         }                                         
904         for (unsigned int conflictLineNumber=0    
905         }                                         
906       }                                           
907       if (listCoefDirHatch.size() != 0) { // a    
908                                                   
909         // now, we have to sort all coef dir f    
910         // and at the same time, reorder the c    
911         // this algorithm is not optimum...       
912         valid = false;                            
913         while (valid ==false )                    
914           {                                       
915             valid = true;                         
916             for (unsigned int sort =0;sort< li    
917               {                                   
918                 if (listCoefDirHatch[sort]>lis    
919                                                   
920                   temp = listCoefDirHatch[sort    
921                   listCoefDirHatch[sort] = lis    
922                   listCoefDirHatch[sort+1] =te    
923                   tempVec = listConflictPoints    
924                   listConflictPoints[sort] = l    
925                   listConflictPoints[sort+1] =    
926                   tempInt = fConflictNumHatchL    
927                   fConflictNumHatchLineTab[hat    
928                   fConflictNumHatchLineTab[hat    
929                   valid= false;                   
930                 }                                 
931               }                                   
932           }                                       
933                                                   
934         // once dir coef have been sort, we co    
935         //witch line had made a conflict ??? c    
936         unsigned int conflictNumber =0;           
937         orderConflictLineNumber.clear();          
938                                                   
939         drawEnabled = false;                      
940         while (conflictNumber < fConflictNumHa    
941           if (conflictNumber+1 == fConflictNum    
942             if(drawEnabled) {                     
943               drawEnabled =  false;               
944               fPoints.push_back(listConflictPo    
945               orderConflictLineNumber.push_bac    
946             }                                     
947           }                                       
948           else {                                  
949             // if the conflict point == next c    
950             // else, this is not a big problem    
951             // (if we were drawing, we have to    
952             if ( !(listConflictPoints[conflict    
953               // special case of nextPointline    
954               unsigned int follow=conflictNumb    
955               bool overContour = false;           
956               while ((follow <fConflictNumHatc    
957                      (listConflictPoints[confl    
958                 follow++;                         
959               }                                   
960               //test if next point is on the c    
961               if(follow < fConflictNumHatchLin    
962                 if ((listConflictPoints[follow    
963                   if ((fConflictNumHatchLineTa    
964                       (fConflictNumHatchLineTa    
965                     if ((listConflictPoints[co    
966                         (listConflictPoints[co    
967                       overContour = true;         
968                     }                             
969                   }                               
970                 }                                 
971               }                                   
972               int previous=conflictNumber-1;      
973               while ((previous >=0) &&            
974                      (listConflictPoints[confl    
975                 previous--;                       
976               }                                   
977               //test if next point is on the c    
978               if(previous >= 0) {                 
979                 if ((listConflictPoints[confli    
980                   if ((listConflictPoints[prev    
981                       (listConflictPoints[prev    
982                     overContour = true;           
983                   }                               
984                 }                                 
985               }                                   
986               if (!overContour) { // we are no    
987                 fPoints.push_back(listConflict    
988                 orderConflictLineNumber.push_b    
989                 drawEnabled = drawEnabled?fals    
990                 if (drawEnabled) {                
991                   fVertices.push_back(2);         
992                 }                                 
993               } else { // else we have to stop    
994                 if (drawEnabled) {                
995                   fPoints.push_back(listConfli    
996                   orderConflictLineNumber.push    
997                   drawEnabled = false;            
998                 }                                 
999               }                                   
1000             }                                    
1001             else { // next point == current      
1002               bool currentPointCrossLine = fa    
1003               bool nextPointCrossLine = false    
1004               // if the conflict is on a line    
1005               // of the previous and next poi    
1006                                                  
1007               // test if conflictPoint == fir    
1008               if (listConflictPoints[conflict    
1009                 // we look second point hatch    
1010                 currentPointConflictHatchNumb    
1011               }                                  
1012               else if (listConflictPoints[con    
1013                 // we look first point hatchN    
1014                 currentPointConflictHatchNumb    
1015               }                                  
1016               else { // case of two lines hav    
1017                 // it is the same case as a "    
1018                 currentPointCrossLine = true;    
1019                 currentPointConflictHatchNumb    
1020               }                                  
1021               // test if conflictPoint == sec    
1022               if (listConflictPoints[conflict    
1023                 // we look second point hatch    
1024                 nextPointConflictHatchNumber     
1025               }                                  
1026               else if (listConflictPoints[con    
1027                 // we look first point hatchN    
1028                 nextPointConflictHatchNumber     
1029               }                                  
1030               else { // case of two lines hav    
1031                 // it is the same case as a "    
1032                 nextPointConflictHatchNumber     
1033                 nextPointCrossLine = true;       
1034               }                                  
1035                                                  
1036               // we have to compute the curre    
1037               // nextPointConflictHatchNumber    
1038               // if they are all the same sid    
1039               // else, we have to draw a line    
1040               if (currentPointCrossLine && ne    
1041                 // do not draw anything, this    
1042                 //  two identical line           
1043               }                                  
1044               // case of two points on  confl    
1045               else if ((!currentPointCrossLin    
1046                 if (drawEnabled) {               
1047                   fPoints.push_back(listConfl    
1048                   orderConflictLineNumber.pus    
1049                   drawEnabled = false;           
1050                 }                                
1051               }                                  
1052               // we draw                         
1053               else if( ( (currentPointConflic    
1054                           fHatchShiftToMatchP    
1055                          (nextPointConflictHa    
1056                           fHatchShiftToMatchP    
1057                         <=FLT_EPSILON) {         
1058                 // try to see if we are tryin    
1059                 unsigned int follow=conflictN    
1060                 bool overContour = false;        
1061                 while ((follow <fConflictNumH    
1062                        (listConflictPoints[co    
1063                   follow++;                      
1064                 }                                
1065                 if(follow < fConflictNumHatch    
1066                   float alpha = 0;               
1067                   bool findAlpha = true;         
1068                   if (listConflictPoints[foll    
1069                     alpha = (listPoints[fConf    
1070                   }                              
1071                   else if (listConflictPoints    
1072                     alpha = (listPoints[fConf    
1073                   }                              
1074                   else if (listConflictPoints    
1075                     alpha = (listPoints[fConf    
1076                   }                              
1077                   else {                         
1078                     findAlpha =false;            
1079                   }                              
1080                   if (findAlpha) {               
1081                     if ((alpha*(listConflictP    
1082                       overContour = true;        
1083                     }                            
1084                   }                              
1085                 }                                
1086                 if (!overContour) { // if we     
1087                   fPoints.push_back(listConfl    
1088                   orderConflictLineNumber.pus    
1089                   drawEnabled = drawEnabled?f    
1090                   if (drawEnabled) {             
1091                     fVertices.push_back(2);      
1092                   }                              
1093                 } else { // else we have to s    
1094                   if (drawEnabled) {             
1095                     fPoints.push_back(listCon    
1096                     orderConflictLineNumber.p    
1097                     drawEnabled = false;         
1098                   }                              
1099                 }                                
1100               }                                  
1101               conflictNumber ++;                 
1102             } // end next== current              
1103           }                                      
1104           conflictNumber ++;                     
1105         } // end while                           
1106         if (drawEnabled) {                       
1107           fPoints.push_back(fPoints[fPoints.s    
1108 #ifdef TOOLS_HATCHER_DEBUG                       
1109           printf("hatcher : Probably a error     
1110 #endif                                           
1111         }                                        
1112         //re put the order conflictNumHatchLi    
1113         fConflictNumHatchLineTab[hatchNumber]    
1114         for(unsigned int a=0;a<orderConflictL    
1115           fConflictNumHatchLineTab[hatchNumbe    
1116                                                  
1117         // test if it is correct                 
1118       } // end resolve system errors             
1119     }  // end conflict                           
1120   }                                              
1121                                                  
1122   if (fPoints.size() >0){                        
1123                                                  
1124     if (precisionError == 0){                    
1125       delete [] listPoints;                      
1126       return true;                               
1127     }                                            
1128     else {                                       
1129 #ifdef TOOLS_HATCHER_DEBUG                       
1130       printf("hatcher : Exit with %d precisio    
1131 #endif                                           
1132       delete [] listPoints;                      
1133       return false;                              
1134     }                                            
1135   }                                              
1136   delete [] listPoints;                          
1137   return true;                                   
1138 }                                                
1139                                                  
1140                                                  
1141                                                  
1142 /////////////////////////////////////////////    
1143 // Compute a vector system equation aA+bB=C      
1144 // return vec2f(0,0) if there is an error        
1145 // set the resolveResult variable to the erro    
1146 // COLINEAR if A and B are                       
1147 // PRECISION_ERROR if there is a lack of prec    
1148 // Z_ERROR if there s no solution for Z          
1149 // UNDEFINED never throw                         
1150 // return a vec2f  for result. a is 'x' value    
1151 /////////////////////////////////////////////    
1152                                                  
1153 inline vec2f hatcher::resolve_system(const ve    
1154                                                  
1155   fResolveResult = RESOLVE_UNDEFINED;            
1156                                                  
1157   double Ax = A[0];                              
1158   double Ay = A[1];                              
1159   double Az = A[2];                              
1160   double Bx = B[0];                              
1161   double By = B[1];                              
1162   double Bz = B[2];                              
1163   double Cx = C[0];                              
1164   double Cy = C[1];                              
1165   double Cz = C[2];                              
1166                                                  
1167   double bDiv = (By*Ax-Ay*Bx);                   
1168   if (ffabs(float(bDiv)) <=FLT_EPSILON) {        
1169     // we have to test in a other order          
1170     double tmp;                                  
1171     tmp = Ax; Ax = Ay; Ay = Az; Az = tmp;        
1172     tmp = Bx; Bx = By; By = Bz; Bz = tmp;        
1173     tmp = Cx; Cx = Cy; Cy = Cz; Cz = tmp;        
1174                                                  
1175     bDiv = (By*Ax-Ay*Bx);                        
1176                                                  
1177     if  (ffabs(float(bDiv)) <=FLT_EPSILON) {     
1178       // we have to test in a other order        
1179       tmp = Ax; Ax = Ay; Ay = Az; Az = tmp;      
1180       tmp = Bx; Bx = By; By = Bz; Bz = tmp;      
1181       tmp = Cx; Cx = Cy; Cy = Cz; Cz = tmp;      
1182                                                  
1183       bDiv = (By*Ax-Ay*Bx);                      
1184       if (ffabs(float(bDiv)) <=FLT_EPSILON) {    
1185         fResolveResult = RESOLVE_COLINEAR;       
1186         return vec2f(0,0);                       
1187       }                                          
1188     }                                            
1189   }                                              
1190   double b= (Cy*Ax-Ay*Cx)/bDiv;                  
1191   double a= -(Cy*Bx-By*Cx)/bDiv;                 
1192   double  bid = ffabs(float(a*Az+b*Bz - Cz));    
1193                                                  
1194   if (bid <= FLT_EPSILON) {                      
1195     fResolveResult = RESOLVE_OK;                 
1196     return vec2f((float)a,(float)b);             
1197   }                                              
1198   else {                                         
1199                                                  
1200     double minBoxValue = 1;                      
1201                                                  
1202     double minXValue =FLT_MAX;                   
1203     double minYValue =FLT_MAX;                   
1204     double minZValue =FLT_MAX;                   
1205     if ((A[0] !=0) && ((A[0]) <minXValue)) mi    
1206     if ((B[0] !=0) && ((B[0]) <minXValue)) mi    
1207     if ((C[0] !=0) && ((C[0]) <minXValue)) mi    
1208     if ((A[1] !=0) && ((A[1]) <minYValue)) mi    
1209     if ((B[1] !=0) && ((B[1]) <minYValue)) mi    
1210     if ((C[1] !=0) && ((C[1]) <minYValue)) mi    
1211     if ((A[2] !=0) && ((A[2]) <minZValue)) mi    
1212     if ((B[2] !=0) && ((B[2]) <minZValue)) mi    
1213     if ((C[2] !=0) && ((C[2]) <minZValue)) mi    
1214                                                  
1215                                                  
1216     double maxXValue =-FLT_MAX;                  
1217     double maxYValue =-FLT_MAX;                  
1218     double maxZValue =-FLT_MAX;                  
1219     if ((A[0] !=0) && ((A[0]) >maxXValue)) ma    
1220     if ((B[0] !=0) && ((B[0]) >maxXValue)) ma    
1221     if ((C[0] !=0) && ((C[0]) >maxXValue)) ma    
1222     if ((A[1] !=0) && ((A[1]) >maxYValue)) ma    
1223     if ((B[1] !=0) && ((B[1]) >maxYValue)) ma    
1224     if ((C[1] !=0) && ((C[1]) >maxYValue)) ma    
1225     if ((A[2] !=0) && ((A[2]) >maxZValue)) ma    
1226     if ((B[2] !=0) && ((B[2]) >maxZValue)) ma    
1227     if ((C[2] !=0) && ((C[2]) >maxZValue)) ma    
1228                                                  
1229     if (((maxXValue-minXValue) <= (maxYValue-    
1230     else                                         
1231       if (((maxYValue-minYValue) <= (maxXValu    
1232       else                                       
1233         { minBoxValue = maxZValue-minZValue;     
1234                                                  
1235     minBoxValue *= fPrecisionFactor;             
1236                                                  
1237     if (bid <= minBoxValue) {                    
1238       fResolveResult = RESOLVE_OK;               
1239       return vec2f((float)a,(float)b);           
1240     }                                            
1241     else {                                       
1242       if (bid>100*minBoxValue) {                 
1243 #ifdef TOOLS_HATCHER_DEBUG                       
1244         printf("hatcher : ***** PRECISON ERRO    
1245 #endif                                           
1246         fResolveResult = RESOLVE_Z_ERROR;        
1247       }                                          
1248       else                                       
1249         {                                        
1250 #ifdef TOOLS_HATCHER_DEBUG                       
1251           printf("hatcher : ***** PRECISON ER    
1252 #endif                                           
1253           fResolveResult = RESOLVE_PRECISION_    
1254         }                                        
1255       //return vec2f(0,0); //G.Barrand : comm    
1256     }                                            
1257   }                                              
1258   return vec2f(0,0);                             
1259 }                                                
1260                                                  
1261 }                                                
1262                                                  
1263 //#undef TOOLS_HATCHER_DEBUG                     
1264