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 11.2)


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