+ idsInRet1Colinear,idsInDescMesh2DForIdsInRetColinear));
+
+ // ### Colinearity fix :
+ // if a node in ret1 has been merged with an already existing node in mesh2D,
+ // we might end up with edges in ret1 that are colinear with some edges in mesh2D
+ // even if none of the edges of the two original meshes were colinear.
+ // this procedure detects such edges and adds them in idsInRet1Colinear/idsInDescMesh2DForIdsInRetColinear
+ // a- find edges in ret1 that are in contact with 2 cells
+ MCAuto<DataArrayDouble> centerOfMassRet1(ret1->computeCellCenterOfMass());
+ MCAuto<DataArrayIdType> cells,cellsIndex;
+ mesh2D->getCellsContainingPoints(centerOfMassRet1->begin(),centerOfMassRet1->getNumberOfTuples(),eps,cells,cellsIndex);
+ MCAuto<DataArrayIdType> cellsIndex2(DataArrayIdType::New()); cellsIndex2->alloc(0,1);
+ if (cellsIndex->getNumberOfTuples() > 1)
+ cellsIndex2 = cellsIndex->deltaShiftIndex();
+ MCAuto<DataArrayIdType> idsInRet1With2Contacts(cellsIndex2->findIdsEqual(2));
+
+ MCAuto<DataArrayIdType> realIdsInDesc2D(desc1->deepCopy());
+ realIdsInDesc2D->abs(); realIdsInDesc2D->applyLin(1,-1);
+ const mcIdType *cRet1(ret1->getNodalConnectivity()->begin()),*ciRet1(ret1->getNodalConnectivityIndex()->begin());
+ for(const mcIdType *it=idsInRet1With2Contacts->begin();it!=idsInRet1With2Contacts->end();it++)
+ {
+ // b- find the edge that the 2 cells in m1Desc have in common:
+ // this is the edge which is colinear with the one in ret1
+ const mcIdType* cellId1 = cells->begin() + cellsIndex->begin()[*it];
+ const mcIdType* cellId2 = cells->begin() + cellsIndex->begin()[*it]+1;
+
+ std::set<mcIdType> s1(realIdsInDesc2D->begin()+dd2->begin()[*cellId1], realIdsInDesc2D->begin()+dd2->begin()[*cellId1+1]);
+ std::set<mcIdType> s2(realIdsInDesc2D->begin()+dd2->begin()[*cellId2], realIdsInDesc2D->begin()+dd2->begin()[*cellId2+1]);
+
+ std::vector<mcIdType> commonEdgeId;
+ std::set_intersection(s1.begin(),s1.end(),s2.begin(),s2.end(), std::back_inserter(commonEdgeId));
+
+ // c- find correct orientation for commonEdgeId
+ const mcIdType* firstNodeInColinearEdgeRet1 = cRet1 + ciRet1[*it]+1;
+ const mcIdType* secondNodeInColinearEdgeRet1 = cRet1 + ciRet1[*it]+2;
+ mcIdType commonEdgeIdCorrectlyOriented;
+ if(IsColinearOfACellOf(intersectEdge1, commonEdgeId, *firstNodeInColinearEdgeRet1,*secondNodeInColinearEdgeRet1, commonEdgeIdCorrectlyOriented))
+ {
+ idsInRet1Colinear->pushBackSilent(*it);
+ idsInDescMesh2DForIdsInRetColinear->pushBackSilent(commonEdgeIdCorrectlyOriented);
+ }
+ }
+ // ### End colinearity fix
+
+ MCAuto<DataArrayIdType> ret3(DataArrayIdType::New()); ret3->alloc(ret1->getNumberOfCells()*2,1); ret3->fillWithValue(std::numeric_limits<mcIdType>::max()); ret3->rearrange(2);
+ MCAuto<DataArrayIdType> idsInRet1NotColinear(idsInRet1Colinear->buildComplement(ret1->getNumberOfCells()));