]> SALOME platform Git repositories - tools/medcoupling.git/commitdiff
Salome HOME
correcting bug (Michael)
authorvbd <vbd>
Tue, 12 Feb 2008 13:01:24 +0000 (13:01 +0000)
committervbd <vbd>
Tue, 12 Feb 2008 13:01:24 +0000 (13:01 +0000)
src/INTERP_KERNEL/PolygonAlgorithms.txx

index f95934cab15762c0ccf29e891d64ebe929fb8483..93f8fceee8b30d2c059fd016e02b2a3c9205197d 100644 (file)
@@ -168,24 +168,24 @@ namespace INTERP_KERNEL
   {    
     if(!_Inter.empty() )
       {
-        if(_End_segments[1] ==i_i_next)
+        if(_End_segments[0] ==i_i_next)
           {
-            for(int idim=0;idim<DIM;idim++) _Inter.push_back(ABCD[idim]);
-            _Terminus= (_End_segments[0]== j_j_next);
-            _End_segments[1] = j_j_next;
+            for(int idim=DIM-1;idim>=0;idim--) _Inter.push_front(ABCD[idim]);
+            _Terminus= (_End_segments[1]== j_j_next);
+            _End_segments[0] = j_j_next;
           }
         else
           {
-            if( _End_segments[1]== j_j_next)
+            if( _End_segments[0]== j_j_next)
               {        
-                for(int idim=0;idim<DIM;idim++) _Inter.push_back(ABCD[idim]);
-                _Terminus= (_End_segments[0]== i_i_next);
-                _End_segments[1] = i_i_next;
+                for(int idim=DIM-1;idim>=0;idim--) _Inter.push_front(ABCD[idim]);
+                _Terminus= (_End_segments[1]== i_i_next);
+                _End_segments[0] = i_i_next;
               }
             else
               {
-                for(int idim=DIM-1;idim>-1;idim--) _Inter.push_front(ABCD[idim]);
-                _End_segments[0] = (_End_segments[0]== i_i_next) ? j_j_next : i_i_next;
+                for(int idim=0;idim<DIM;idim++) _Inter.push_back(ABCD[idim]);
+                _End_segments[1] = (_End_segments[1]== i_i_next) ? j_j_next : i_i_next;
               }
           }
       }      
@@ -210,18 +210,32 @@ namespace INTERP_KERNEL
   void PolygonAlgorithms<DIM>::add_crossing0(const double * A, const double * B, int i, int i_next,
                                              const double * C, const double * D, int j, int j_next)
   {
-    double ABCD[DIM];
+    double ABCD[DIM];          
     if(intersect_segment_segment(A,B,C,D,ABCD, ABCD))
       //fifth and sixth arguments are useless here
       {
-        add_crossing(ABCD, std::make_pair(i, i_next),  std::make_pair(j, j_next));  
-        _Status.insert(std::make_pair(i_next,std::make_pair(i, false)));
-        std::multimap< int, std::pair< int,bool> >::iterator mi;
-        mi=_Status.find(j_next);
-        ((* mi).second).second= !((* mi).second).second;
+                               /* Updating _End_segments */
+                               pair< int,int > i_i_next = make_pair(i, i_next);
+                               pair< int,int > j_j_next = make_pair(j, j_next); 
+                                               if( _End_segments[0] == i_i_next)
+                                                       {        
+                                                               for(int idim=DIM-1;idim>-1;idim--) _Inter.push_front(ABCD[idim]);
+                                                               _End_segments[0] = j_j_next;
+                                                       }
+                                               else 
+                                                       {
+                                                               for(int idim=0;idim<DIM;idim++) _Inter.push_back(ABCD[idim]);
+                                                               _End_segments[1] = j_j_next;
+                                                               _Terminus = _End_segments[0]== j_j_next;
+                                                       }
+        
+        /* Updating _Status */
+       _Status.insert(make_pair(i_next,make_pair(i, false)));
+       multimap< int, pair< int,bool> >::iterator mi =_Status.find(j_next);
+       ((* mi).second).second= !((* mi).second).second;
       }
-    else       _Status.insert(std::make_pair(i_next,std::make_pair(i,true)));
-  }  
+    else       _Status.insert(make_pair(i_next,make_pair(i,true)));
+   }  
 
   /*******************************************************/
   /* adds the possible crossings between segments [A,B] (with end-point global indices i and i_next) */