{
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;
}
}
}
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) */