-/*!
- * Partitions the first given 2D mesh using the second given 2D mesh as a tool, and
- * returns a result mesh constituted by polygons.
- * Thus the final result contains all nodes from m1 plus new nodes. However it doesn't necessarily contains
- * all nodes from m2.
- * The meshes should be in 2D space. In
- * addition, returns two arrays mapping cells of the result mesh to cells of the input
- * meshes.
- * \param [in] m1 - the first input mesh which is a partitioned object. The mesh must be so that each point in the space covered by \a m1
- * must be covered exactly by one entity, \b no \b more. If it is not the case, some tools are available to heal the mesh (conformize2D, mergeNodes)
- * \param [in] m2 - the second input mesh which is a partition tool. The mesh must be so that each point in the space covered by \a m2
- * must be covered exactly by one entity, \b no \b more. If it is not the case, some tools are available to heal the mesh (conformize2D, mergeNodes)
- * \param [in] eps - precision used to detect coincident mesh entities.
- * \param [out] cellNb1 - a new instance of DataArrayInt holding for each result
- * cell an id of the cell of \a m1 it comes from. The caller is to delete
- * this array using decrRef() as it is no more needed.
- * \param [out] cellNb2 - a new instance of DataArrayInt holding for each result
- * cell an id of the cell of \a m2 it comes from. -1 value means that a
- * result cell comes from a cell (or part of cell) of \a m1 not overlapped by
- * any cell of \a m2. The caller is to delete this array using decrRef() as
- * it is no more needed.
- * \return MEDCouplingUMesh * - the result 2D mesh which is a new instance of
- * MEDCouplingUMesh. The caller is to delete this mesh using decrRef() as it
- * is no more needed.
- * \throw If the coordinates array is not set in any of the meshes.
- * \throw If the nodal connectivity of cells is not defined in any of the meshes.
- * \throw If any of the meshes is not a 2D mesh in 2D space.
- *
- * \sa conformize2D, mergeNodes
- */
-MEDCouplingUMesh *MEDCouplingUMesh::Intersect2DMeshes(const MEDCouplingUMesh *m1, const MEDCouplingUMesh *m2,
- double eps, DataArrayInt *&cellNb1, DataArrayInt *&cellNb2)
-{
- if(!m1 || !m2)
- throw INTERP_KERNEL::Exception("MEDCouplingUMesh::Intersect2DMeshes : input meshes must be not NULL !");
- m1->checkFullyDefined();
- m2->checkFullyDefined();
- if(m1->getMeshDimension()!=2 || m1->getSpaceDimension()!=2 || m2->getMeshDimension()!=2 || m2->getSpaceDimension()!=2)
- throw INTERP_KERNEL::Exception("MEDCouplingUMesh::Intersect2DMeshes works on umeshes m1 AND m2 with meshdim equal to 2 and spaceDim equal to 2 too!");
-
- // Step 1: compute all edge intersections (new nodes)
- std::vector< std::vector<int> > intersectEdge1, colinear2, subDiv2;
- MEDCouplingUMesh *m1Desc=0,*m2Desc=0; // descending connec. meshes
- DataArrayInt *desc1=0,*descIndx1=0,*revDesc1=0,*revDescIndx1=0,*desc2=0,*descIndx2=0,*revDesc2=0,*revDescIndx2=0;
- std::vector<double> addCoo,addCoordsQuadratic; // coordinates of newly created nodes
- IntersectDescending2DMeshes(m1,m2,eps,intersectEdge1,colinear2, subDiv2,
- m1Desc,desc1,descIndx1,revDesc1,revDescIndx1,
- addCoo, m2Desc,desc2,descIndx2,revDesc2,revDescIndx2);
- revDesc1->decrRef(); revDescIndx1->decrRef(); revDesc2->decrRef(); revDescIndx2->decrRef();
- MEDCouplingAutoRefCountObjectPtr<DataArrayInt> dd1(desc1),dd2(descIndx1),dd3(desc2),dd4(descIndx2);
- MEDCouplingAutoRefCountObjectPtr<MEDCouplingUMesh> dd5(m1Desc),dd6(m2Desc);
-
- // Step 2: re-order newly created nodes according to the ordering found in m2
- std::vector< std::vector<int> > intersectEdge2;
- BuildIntersectEdges(m1Desc,m2Desc,addCoo,subDiv2,intersectEdge2);
- subDiv2.clear(); dd5=0; dd6=0;
-
- // Step 3:
- std::vector<int> cr,crI; //no DataArrayInt because interface with Geometric2D
- std::vector<int> cNb1,cNb2; //no DataArrayInt because interface with Geometric2D
- BuildIntersecting2DCellsFromEdges(eps,m1,desc1->getConstPointer(),descIndx1->getConstPointer(),intersectEdge1,colinear2,m2,desc2->getConstPointer(),descIndx2->getConstPointer(),intersectEdge2,addCoo,
- /* outputs -> */addCoordsQuadratic,cr,crI,cNb1,cNb2);
-
- // Step 4: Prepare final result:
- MEDCouplingAutoRefCountObjectPtr<DataArrayDouble> addCooDa(DataArrayDouble::New());
- addCooDa->alloc((int)(addCoo.size())/2,2);
- std::copy(addCoo.begin(),addCoo.end(),addCooDa->getPointer());
- MEDCouplingAutoRefCountObjectPtr<DataArrayDouble> addCoordsQuadraticDa(DataArrayDouble::New());
- addCoordsQuadraticDa->alloc((int)(addCoordsQuadratic.size())/2,2);
- std::copy(addCoordsQuadratic.begin(),addCoordsQuadratic.end(),addCoordsQuadraticDa->getPointer());
- std::vector<const DataArrayDouble *> coordss(4);
- coordss[0]=m1->getCoords(); coordss[1]=m2->getCoords(); coordss[2]=addCooDa; coordss[3]=addCoordsQuadraticDa;
- MEDCouplingAutoRefCountObjectPtr<DataArrayDouble> coo(DataArrayDouble::Aggregate(coordss));
- MEDCouplingAutoRefCountObjectPtr<MEDCouplingUMesh> ret(MEDCouplingUMesh::New("Intersect2D",2));
- MEDCouplingAutoRefCountObjectPtr<DataArrayInt> conn(DataArrayInt::New()); conn->alloc((int)cr.size(),1); std::copy(cr.begin(),cr.end(),conn->getPointer());
- MEDCouplingAutoRefCountObjectPtr<DataArrayInt> connI(DataArrayInt::New()); connI->alloc((int)crI.size(),1); std::copy(crI.begin(),crI.end(),connI->getPointer());
- MEDCouplingAutoRefCountObjectPtr<DataArrayInt> c1(DataArrayInt::New()); c1->alloc((int)cNb1.size(),1); std::copy(cNb1.begin(),cNb1.end(),c1->getPointer());
- MEDCouplingAutoRefCountObjectPtr<DataArrayInt> c2(DataArrayInt::New()); c2->alloc((int)cNb2.size(),1); std::copy(cNb2.begin(),cNb2.end(),c2->getPointer());
- ret->setConnectivity(conn,connI,true);
- ret->setCoords(coo);
- cellNb1=c1.retn(); cellNb2=c2.retn();
- return ret.retn();
-}
-
-/// @cond INTERNAL
-
-bool IsColinearOfACellOf(const std::vector< std::vector<int> >& intersectEdge1, const std::vector<int>& candidates, int start, int stop, int& retVal)
-{
- if(candidates.empty())
- return false;
- for(std::vector<int>::const_iterator it=candidates.begin();it!=candidates.end();it++)
- {
- const std::vector<int>& pool(intersectEdge1[*it]);
- int tmp[2]; tmp[0]=start; tmp[1]=stop;
- if(std::search(pool.begin(),pool.end(),tmp,tmp+2)!=pool.end())
- {
- retVal=*it+1;
- return true;
- }
- tmp[0]=stop; tmp[1]=start;
- if(std::search(pool.begin(),pool.end(),tmp,tmp+2)!=pool.end())
- {
- retVal=-*it-1;
- return true;
- }
- }
- return false;
-}
-
-MEDCouplingUMesh *BuildMesh1DCutFrom(const MEDCouplingUMesh *mesh1D, const std::vector< std::vector<int> >& intersectEdge2, const DataArrayDouble *coords1, const std::vector<double>& addCoo, const std::map<int,int>& mergedNodes, const std::vector< std::vector<int> >& colinear2, const std::vector< std::vector<int> >& intersectEdge1,
- MEDCouplingAutoRefCountObjectPtr<DataArrayInt>& idsInRetColinear, MEDCouplingAutoRefCountObjectPtr<DataArrayInt>& idsInMesh1DForIdsInRetColinear)
-{
- idsInRetColinear=DataArrayInt::New(); idsInRetColinear->alloc(0,1);
- idsInMesh1DForIdsInRetColinear=DataArrayInt::New(); idsInMesh1DForIdsInRetColinear->alloc(0,1);
- int nCells(mesh1D->getNumberOfCells());
- if(nCells!=(int)intersectEdge2.size())
- throw INTERP_KERNEL::Exception("BuildMesh1DCutFrom : internal error # 1 !");
- const DataArrayDouble *coo2(mesh1D->getCoords());
- const int *c(mesh1D->getNodalConnectivity()->begin()),*ci(mesh1D->getNodalConnectivityIndex()->begin());
- const double *coo2Ptr(coo2->begin());
- int offset1(coords1->getNumberOfTuples());
- int offset2(offset1+coo2->getNumberOfTuples());
- int offset3(offset2+addCoo.size()/2);
- std::vector<double> addCooQuad;
- MEDCouplingAutoRefCountObjectPtr<DataArrayInt> cOut(DataArrayInt::New()),ciOut(DataArrayInt::New()); cOut->alloc(0,1); ciOut->alloc(1,1); ciOut->setIJ(0,0,0);
- int tmp[4],cicnt(0),kk(0);
- for(int i=0;i<nCells;i++)
- {
- std::map<MEDCouplingAutoRefCountObjectPtr<INTERP_KERNEL::Node>,int> m;
- INTERP_KERNEL::Edge *e(MEDCouplingUMeshBuildQPFromEdge2((INTERP_KERNEL::NormalizedCellType)c[ci[i]],c+ci[i]+1,coo2Ptr,m));
- const std::vector<int>& subEdges(intersectEdge2[i]);
- int nbSubEdge(subEdges.size()/2);
- for(int j=0;j<nbSubEdge;j++,kk++)
- {
- MEDCouplingAutoRefCountObjectPtr<INTERP_KERNEL::Node> n1(MEDCouplingUMeshBuildQPNode(subEdges[2*j],coords1->begin(),offset1,coo2Ptr,offset2,addCoo)),n2(MEDCouplingUMeshBuildQPNode(subEdges[2*j+1],coords1->begin(),offset1,coo2Ptr,offset2,addCoo));
- MEDCouplingAutoRefCountObjectPtr<INTERP_KERNEL::Edge> e2(e->buildEdgeLyingOnMe(n1,n2));
- INTERP_KERNEL::Edge *e2Ptr(e2);
- std::map<int,int>::const_iterator itm;
- if(dynamic_cast<INTERP_KERNEL::EdgeArcCircle *>(e2Ptr))
- {
- tmp[0]=INTERP_KERNEL::NORM_SEG3;
- itm=mergedNodes.find(subEdges[2*j]);
- tmp[1]=itm!=mergedNodes.end()?(*itm).second:subEdges[2*j];
- itm=mergedNodes.find(subEdges[2*j+1]);
- tmp[2]=itm!=mergedNodes.end()?(*itm).second:subEdges[2*j+1];
- tmp[3]=offset3+(int)addCooQuad.size()/2;
- double tmp2[2];
- e2->getBarycenter(tmp2); addCooQuad.insert(addCooQuad.end(),tmp2,tmp2+2);
- cicnt+=4;
- cOut->insertAtTheEnd(tmp,tmp+4);
- ciOut->pushBackSilent(cicnt);
- }
- else
- {
- tmp[0]=INTERP_KERNEL::NORM_SEG2;
- itm=mergedNodes.find(subEdges[2*j]);
- tmp[1]=itm!=mergedNodes.end()?(*itm).second:subEdges[2*j];
- itm=mergedNodes.find(subEdges[2*j+1]);
- tmp[2]=itm!=mergedNodes.end()?(*itm).second:subEdges[2*j+1];
- cicnt+=3;
- cOut->insertAtTheEnd(tmp,tmp+3);
- ciOut->pushBackSilent(cicnt);
- }
- int tmp00;
- if(IsColinearOfACellOf(intersectEdge1,colinear2[i],tmp[1],tmp[2],tmp00))
- {
- idsInRetColinear->pushBackSilent(kk);
- idsInMesh1DForIdsInRetColinear->pushBackSilent(tmp00);
- }
- }
- e->decrRef();
- }
- MEDCouplingAutoRefCountObjectPtr<MEDCouplingUMesh> ret(MEDCouplingUMesh::New(mesh1D->getName(),1));
- ret->setConnectivity(cOut,ciOut,true);
- MEDCouplingAutoRefCountObjectPtr<DataArrayDouble> arr3(DataArrayDouble::New());
- arr3->useArray(&addCoo[0],false,C_DEALLOC,(int)addCoo.size()/2,2);
- MEDCouplingAutoRefCountObjectPtr<DataArrayDouble> arr4(DataArrayDouble::New()); arr4->useArray(&addCooQuad[0],false,C_DEALLOC,(int)addCooQuad.size()/2,2);
- std::vector<const DataArrayDouble *> coordss(4);
- coordss[0]=coords1; coordss[1]=mesh1D->getCoords(); coordss[2]=arr3; coordss[3]=arr4;
- MEDCouplingAutoRefCountObjectPtr<DataArrayDouble> arr(DataArrayDouble::Aggregate(coordss));
- ret->setCoords(arr);
- return ret.retn();
-}
-
-MEDCouplingUMesh *BuildRefined2DCellLinear(const DataArrayDouble *coords, const int *descBg, const int *descEnd, const std::vector< std::vector<int> >& intersectEdge1)
-{
- std::vector<int> allEdges;
- for(const int *it2(descBg);it2!=descEnd;it2++)
- {
- const std::vector<int>& edge1(intersectEdge1[std::abs(*it2)-1]);
- if(*it2>0)
- allEdges.insert(allEdges.end(),edge1.begin(),edge1.end());
- else
- allEdges.insert(allEdges.end(),edge1.rbegin(),edge1.rend());
- }
- std::size_t nb(allEdges.size());
- if(nb%2!=0)
- throw INTERP_KERNEL::Exception("BuildRefined2DCellLinear : internal error 1 !");
- std::size_t nbOfEdgesOf2DCellSplit(nb/2);
- MEDCouplingAutoRefCountObjectPtr<MEDCouplingUMesh> ret(MEDCouplingUMesh::New("",2));
- ret->setCoords(coords);
- ret->allocateCells(1);
- std::vector<int> connOut(nbOfEdgesOf2DCellSplit);
- for(std::size_t kk=0;kk<nbOfEdgesOf2DCellSplit;kk++)
- connOut[kk]=allEdges[2*kk];
- ret->insertNextCell(INTERP_KERNEL::NORM_POLYGON,connOut.size(),&connOut[0]);
- return ret.retn();
-}
-
-MEDCouplingUMesh *BuildRefined2DCellQuadratic(const DataArrayDouble *coords, const MEDCouplingUMesh *mesh2D, int cellIdInMesh2D, const int *descBg, const int *descEnd, const std::vector< std::vector<int> >& intersectEdge1)
-{
- const int *c(mesh2D->getNodalConnectivity()->begin()),*ci(mesh2D->getNodalConnectivityIndex()->begin());
- const INTERP_KERNEL::CellModel& cm(INTERP_KERNEL::CellModel::GetCellModel((INTERP_KERNEL::NormalizedCellType)c[ci[cellIdInMesh2D]]));
- std::size_t ii(0);
- unsigned sz(cm.getNumberOfSons2(c+ci[cellIdInMesh2D]+1,ci[cellIdInMesh2D+1]-ci[cellIdInMesh2D]-1));
- if(sz!=std::distance(descBg,descEnd))
- throw INTERP_KERNEL::Exception("BuildRefined2DCellQuadratic : internal error 1 !");
- INTERP_KERNEL::AutoPtr<int> tmpPtr(new int[ci[cellIdInMesh2D+1]-ci[cellIdInMesh2D]]);
- std::vector<int> allEdges,centers;
- const double *coordsPtr(coords->begin());
- MEDCouplingAutoRefCountObjectPtr<DataArrayDouble> addCoo(DataArrayDouble::New()); addCoo->alloc(0,1);
- int offset(coords->getNumberOfTuples());
- for(const int *it2(descBg);it2!=descEnd;it2++,ii++)
- {
- INTERP_KERNEL::NormalizedCellType typeOfSon;
- cm.fillSonCellNodalConnectivity2(ii,c+ci[cellIdInMesh2D]+1,ci[cellIdInMesh2D+1]-ci[cellIdInMesh2D]-1,tmpPtr,typeOfSon);
- const std::vector<int>& edge1(intersectEdge1[std::abs(*it2)-1]);
- if(*it2>0)
- allEdges.insert(allEdges.end(),edge1.begin(),edge1.end());
- else
- allEdges.insert(allEdges.end(),edge1.rbegin(),edge1.rend());
- if(edge1.size()==2)
- centers.push_back(tmpPtr[2]);//special case where no subsplit of edge -> reuse the original center.
- else
- {//the current edge has been subsplit -> create corresponding centers.
- std::size_t nbOfCentersToAppend(edge1.size()/2);
- std::map< MEDCouplingAutoRefCountObjectPtr<INTERP_KERNEL::Node>,int> m;
- MEDCouplingAutoRefCountObjectPtr<INTERP_KERNEL::Edge> ee(MEDCouplingUMeshBuildQPFromEdge2(typeOfSon,tmpPtr,coordsPtr,m));
- std::vector<int>::const_iterator it3(allEdges.end()-edge1.size());
- for(std::size_t k=0;k<nbOfCentersToAppend;k++)
- {
- double tmpp[2];
- const double *aa(coordsPtr+2*(*it3++));
- const double *bb(coordsPtr+2*(*it3++));
- ee->getMiddleOfPoints(aa,bb,tmpp);
- addCoo->insertAtTheEnd(tmpp,tmpp+2);
- centers.push_back(offset+k);
- }
- }
- }
- std::size_t nb(allEdges.size());
- if(nb%2!=0)
- throw INTERP_KERNEL::Exception("BuildRefined2DCellQuadratic : internal error 2 !");
- std::size_t nbOfEdgesOf2DCellSplit(nb/2);
- MEDCouplingAutoRefCountObjectPtr<MEDCouplingUMesh> ret(MEDCouplingUMesh::New("",2));
- if(addCoo->empty())
- ret->setCoords(coords);
- else
- {
- addCoo->rearrange(2);
- addCoo=DataArrayDouble::Aggregate(coords,addCoo);
- ret->setCoords(addCoo);
- }
- ret->allocateCells(1);
- std::vector<int> connOut(nbOfEdgesOf2DCellSplit);
- for(std::size_t kk=0;kk<nbOfEdgesOf2DCellSplit;kk++)
- connOut[kk]=allEdges[2*kk];
- connOut.insert(connOut.end(),centers.begin(),centers.end());
- ret->insertNextCell(INTERP_KERNEL::NORM_QPOLYG,connOut.size(),&connOut[0]);
- return ret.retn();
-}
-
-/*!
- * This method creates a refinement of a cell in \a mesh2D. Those cell is defined by descending connectivity and the sorted subdivided nodal connectivity
- * of those edges.
- *
- * \param [in] mesh2D - The origin 2D mesh. \b Warning \b coords are not those of \a mesh2D. But mesh2D->getCoords()==coords[:mesh2D->getNumberOfNodes()]
- */
-MEDCouplingUMesh *BuildRefined2DCell(const DataArrayDouble *coords, const MEDCouplingUMesh *mesh2D, int cellIdInMesh2D, const int *descBg, const int *descEnd, const std::vector< std::vector<int> >& intersectEdge1)
-{
- const INTERP_KERNEL::CellModel& cm(INTERP_KERNEL::CellModel::GetCellModel(mesh2D->getTypeOfCell(cellIdInMesh2D)));
- if(!cm.isQuadratic())
- return BuildRefined2DCellLinear(coords,descBg,descEnd,intersectEdge1);
- else
- return BuildRefined2DCellQuadratic(coords,mesh2D,cellIdInMesh2D,descBg,descEnd,intersectEdge1);
-}
-
-void AddCellInMesh2D(MEDCouplingUMesh *mesh2D, const std::vector<int>& conn, const std::vector< MEDCouplingAutoRefCountObjectPtr<INTERP_KERNEL::Edge> >& edges)
-{
- bool isQuad(false);
- for(std::vector< MEDCouplingAutoRefCountObjectPtr<INTERP_KERNEL::Edge> >::const_iterator it=edges.begin();it!=edges.end();it++)
- {
- const INTERP_KERNEL::Edge *ee(*it);
- if(dynamic_cast<const INTERP_KERNEL::EdgeArcCircle *>(ee))
- isQuad=true;
- }
- if(!isQuad)
- mesh2D->insertNextCell(INTERP_KERNEL::NORM_POLYGON,conn.size(),&conn[0]);
- else
- {
- const double *coo(mesh2D->getCoords()->begin());
- std::size_t sz(conn.size());
- std::vector<double> addCoo;
- std::vector<int> conn2(conn);
- int offset(mesh2D->getNumberOfNodes());
- for(std::size_t i=0;i<sz;i++)
- {
- double tmp[2];
- edges[(i+1)%sz]->getMiddleOfPoints(coo+2*conn[i],coo+2*conn[(i+1)%sz],tmp);// tony a chier i+1 -> i
- addCoo.insert(addCoo.end(),tmp,tmp+2);
- conn2.push_back(offset+(int)i);
- }
- mesh2D->getCoords()->rearrange(1);
- mesh2D->getCoords()->pushBackValsSilent(&addCoo[0],&addCoo[0]+addCoo.size());
- mesh2D->getCoords()->rearrange(2);
- mesh2D->insertNextCell(INTERP_KERNEL::NORM_QPOLYG,conn2.size(),&conn2[0]);
- }
-}
-
-/*!
- * \b WARNING edges in out1 coming from \a splitMesh1D are \b NOT oriented because only used for equation of curve.
- *
- * This method cuts in 2 parts the input 2D cell given using boundaries description (\a edge1Bis and \a edge1BisPtr) using
- * a set of edges defined in \a splitMesh1D.
- */
-void BuildMesh2DCutInternal2(const MEDCouplingUMesh *splitMesh1D, const std::vector<int>& edge1Bis, const std::vector< MEDCouplingAutoRefCountObjectPtr<INTERP_KERNEL::Edge> >& edge1BisPtr,
- std::vector< std::vector<int> >& out0, std::vector< std::vector< MEDCouplingAutoRefCountObjectPtr<INTERP_KERNEL::Edge> > >& out1)
-{
- std::size_t nb(edge1Bis.size()/2);
- std::size_t nbOfEdgesOf2DCellSplit(nb/2);
- int iEnd(splitMesh1D->getNumberOfCells());
- if(iEnd==0)
- throw INTERP_KERNEL::Exception("BuildMesh2DCutInternal2 : internal error ! input 1D mesh must have at least one cell !");
- std::size_t ii,jj;
- const int *cSplitPtr(splitMesh1D->getNodalConnectivity()->begin()),*ciSplitPtr(splitMesh1D->getNodalConnectivityIndex()->begin());
- for(ii=0;ii<nb && edge1Bis[2*ii]!=cSplitPtr[ciSplitPtr[0]+1];ii++);
- for(jj=ii;jj<nb && edge1Bis[2*jj+1]!=cSplitPtr[ciSplitPtr[iEnd-1]+2];jj++);
- //
- if(jj==nb)
- {//the edges splitMesh1D[iStart:iEnd] does not fully cut the current 2D cell -> single output cell
- out0.resize(1); out1.resize(1);
- std::vector<int>& connOut(out0[0]);
- connOut.resize(nbOfEdgesOf2DCellSplit);
- std::vector< MEDCouplingAutoRefCountObjectPtr<INTERP_KERNEL::Edge> >& edgesPtr(out1[0]);
- edgesPtr.resize(nbOfEdgesOf2DCellSplit);
- for(std::size_t kk=0;kk<nbOfEdgesOf2DCellSplit;kk++)
- {
- connOut[kk]=edge1Bis[2*kk];
- edgesPtr[kk]=edge1BisPtr[2*kk];
- }
- }
- else
- {
- // [i,iEnd[ contains the
- out0.resize(2); out1.resize(2);
- std::vector<int>& connOutLeft(out0[0]);
- std::vector<int>& connOutRight(out0[1]);//connOutLeft should end with edge1Bis[2*ii] and connOutRight should end with edge1Bis[2*jj+1]
- std::vector< MEDCouplingAutoRefCountObjectPtr<INTERP_KERNEL::Edge> >& eleft(out1[0]);
- std::vector< MEDCouplingAutoRefCountObjectPtr<INTERP_KERNEL::Edge> >& eright(out1[1]);
- for(std::size_t k=ii;k<jj+1;k++)
- { connOutLeft.push_back(edge1Bis[2*k+1]); eleft.push_back(edge1BisPtr[2*k+1]); }
- std::vector< MEDCouplingAutoRefCountObjectPtr<INTERP_KERNEL::Edge> > ees(iEnd);
- for(int ik=0;ik<iEnd;ik++)
- {
- std::map< MEDCouplingAutoRefCountObjectPtr<INTERP_KERNEL::Node>,int> m;
- MEDCouplingAutoRefCountObjectPtr<INTERP_KERNEL::Edge> ee(MEDCouplingUMeshBuildQPFromEdge2((INTERP_KERNEL::NormalizedCellType)cSplitPtr[ciSplitPtr[ik]],cSplitPtr+ciSplitPtr[ik]+1,splitMesh1D->getCoords()->begin(),m));
- ees[ik]=ee;
- }
- for(int ik=iEnd-1;ik>=0;ik--)
- connOutLeft.push_back(cSplitPtr[ciSplitPtr[ik]+1]);
- for(std::size_t k=jj+1;k<nbOfEdgesOf2DCellSplit+ii;k++)
- { connOutRight.push_back(edge1Bis[2*k+1]); eright.push_back(edge1BisPtr[2*k+1]); }
- eleft.insert(eleft.end(),ees.rbegin(),ees.rend());
- for(int ik=0;ik<iEnd;ik++)
- connOutRight.push_back(cSplitPtr[ciSplitPtr[ik]+2]);
- eright.insert(eright.end(),ees.begin(),ees.end());
- }
-}
-
-/// @endcond
-
-/// @cond INTERNAL
-
-struct CellInfo
-{
-public:
- CellInfo() { }
- CellInfo(const std::vector<int>& edges, const std::vector< MEDCouplingAutoRefCountObjectPtr<INTERP_KERNEL::Edge> >& edgesPtr);
-public:
- std::vector<int> _edges;
- std::vector< MEDCouplingAutoRefCountObjectPtr<INTERP_KERNEL::Edge> > _edges_ptr;
-};
-
-CellInfo::CellInfo(const std::vector<int>& edges, const std::vector< MEDCouplingAutoRefCountObjectPtr<INTERP_KERNEL::Edge> >& edgesPtr)
-{
- std::size_t nbe(edges.size());
- std::vector<int> edges2(2*nbe); std::vector< MEDCouplingAutoRefCountObjectPtr<INTERP_KERNEL::Edge> > edgesPtr2(2*nbe);
- for(std::size_t i=0;i<nbe;i++)
- {
- edges2[2*i]=edges[i]; edges2[2*i+1]=edges[(i+1)%nbe];
- edgesPtr2[2*i]=edgesPtr[(i+1)%nbe]; edgesPtr2[2*i+1]=edgesPtr[(i+1)%nbe];//tony a chier
- }
- _edges.resize(4*nbe); _edges_ptr.resize(4*nbe);
- std::copy(edges2.begin(),edges2.end(),_edges.begin()); std::copy(edges2.begin(),edges2.end(),_edges.begin()+2*nbe);
- std::copy(edgesPtr2.begin(),edgesPtr2.end(),_edges_ptr.begin()); std::copy(edgesPtr2.begin(),edgesPtr2.end(),_edges_ptr.begin()+2*nbe);
-}
-
-class EdgeInfo
-{
-public:
- EdgeInfo(int istart, int iend, const MEDCouplingAutoRefCountObjectPtr<MEDCouplingUMesh>& mesh):_istart(istart),_iend(iend),_mesh(mesh),_left(-7),_right(-7) { }
- EdgeInfo(int istart, int iend, int pos, const MEDCouplingAutoRefCountObjectPtr<INTERP_KERNEL::Edge>& edge):_istart(istart),_iend(iend),_edge(edge),_left(pos),_right(pos+1) { }
- bool isInMyRange(int pos) const { return pos>=_istart && pos<_iend; }
- void somethingHappendAt(int pos, const std::vector< MEDCouplingAutoRefCountObjectPtr<INTERP_KERNEL::Edge> >& newLeft, const std::vector< MEDCouplingAutoRefCountObjectPtr<INTERP_KERNEL::Edge> >& newRight);
- void feedEdgeInfoAt(double eps, const MEDCouplingUMesh *mesh2D, int offset, int neighbors[2]) const;
-private:
- int _istart;
- int _iend;
- MEDCouplingAutoRefCountObjectPtr<MEDCouplingUMesh> _mesh;
- MEDCouplingAutoRefCountObjectPtr<INTERP_KERNEL::Edge> _edge;
- int _left;
- int _right;
-};
-
-void EdgeInfo::somethingHappendAt(int pos, const std::vector< MEDCouplingAutoRefCountObjectPtr<INTERP_KERNEL::Edge> >& newLeft, const std::vector< MEDCouplingAutoRefCountObjectPtr<INTERP_KERNEL::Edge> >& newRight)
-{
- const MEDCouplingUMesh *mesh(_mesh);
- if(mesh)
- return ;
- if(_right<pos)
- return ;
- if(_left>pos)
- { _left++; _right++; return ; }
- if(_right==pos)
- {
- bool isLeft(std::find(newLeft.begin(),newLeft.end(),_edge)!=newLeft.end()),isRight(std::find(newRight.begin(),newRight.end(),_edge)!=newRight.end());
- if((isLeft && isRight) || (!isLeft && !isRight))
- throw INTERP_KERNEL::Exception("EdgeInfo::somethingHappendAt : internal error # 1 !");
- if(isLeft)
- return ;
- if(isRight)
- {
- _right++;
- return ;
- }
- }
- if(_left==pos)
- {
- bool isLeft(std::find(newLeft.begin(),newLeft.end(),_edge)!=newLeft.end()),isRight(std::find(newRight.begin(),newRight.end(),_edge)!=newRight.end());
- if((isLeft && isRight) || (!isLeft && !isRight))
- throw INTERP_KERNEL::Exception("EdgeInfo::somethingHappendAt : internal error # 2 !");
- if(isLeft)
- {
- _right++;
- return ;
- }
- if(isRight)
- {
- _left++;
- _right++;
- return ;
- }
- }
-}
-
-void EdgeInfo::feedEdgeInfoAt(double eps, const MEDCouplingUMesh *mesh2D, int offset, int neighbors[2]) const
-{
- const MEDCouplingUMesh *mesh(_mesh);
- if(!mesh)
- {
- neighbors[0]=offset+_left; neighbors[1]=offset+_right;
- }
- else
- {// not fully splitting cell case
- if(mesh2D->getNumberOfCells()==1)
- {//little optimization. 1 cell no need to find in which cell mesh is !
- neighbors[0]=offset; neighbors[1]=offset;
- return;
- }
- else
- {
- MEDCouplingAutoRefCountObjectPtr<DataArrayDouble> barys(mesh->getBarycenterAndOwner());
- int cellId(mesh2D->getCellContainingPoint(barys->begin(),eps));
- if(cellId==-1)
- throw INTERP_KERNEL::Exception("EdgeInfo::feedEdgeInfoAt : internal error !");
- neighbors[0]=offset+cellId; neighbors[1]=offset+cellId;
- }
- }
-}
-
-class VectorOfCellInfo
-{
-public:
- VectorOfCellInfo(const std::vector<int>& edges, const std::vector< MEDCouplingAutoRefCountObjectPtr<INTERP_KERNEL::Edge> >& edgesPtr);
- std::size_t size() const { return _pool.size(); }
- int getPositionOf(double eps, const MEDCouplingUMesh *mesh) const;
- void setMeshAt(int pos, const MEDCouplingAutoRefCountObjectPtr<MEDCouplingUMesh>& mesh, int istart, int iend, const MEDCouplingAutoRefCountObjectPtr<MEDCouplingUMesh>& mesh1DInCase, const std::vector< std::vector<int> >& edges, const std::vector< std::vector< MEDCouplingAutoRefCountObjectPtr<INTERP_KERNEL::Edge> > >& edgePtrs);
- const std::vector<int>& getConnOf(int pos) const { return get(pos)._edges; }
- const std::vector< MEDCouplingAutoRefCountObjectPtr<INTERP_KERNEL::Edge> >& getEdgePtrOf(int pos) const { return get(pos)._edges_ptr; }
- MEDCouplingAutoRefCountObjectPtr<MEDCouplingUMesh> getZeMesh() const { return _ze_mesh; }
- void feedEdgeInfoAt(double eps, int pos, int offset, int neighbors[2]) const;
-private:
- int getZePosOfEdgeGivenItsGlobalId(int pos) const;
- void updateEdgeInfo(int pos, const std::vector< MEDCouplingAutoRefCountObjectPtr<INTERP_KERNEL::Edge> >& newLeft, const std::vector< MEDCouplingAutoRefCountObjectPtr<INTERP_KERNEL::Edge> >& newRight);
- const CellInfo& get(int pos) const;
- CellInfo& get(int pos);
-private:
- std::vector<CellInfo> _pool;
- MEDCouplingAutoRefCountObjectPtr<MEDCouplingUMesh> _ze_mesh;
- std::vector<EdgeInfo> _edge_info;
-};
-
-VectorOfCellInfo::VectorOfCellInfo(const std::vector<int>& edges, const std::vector< MEDCouplingAutoRefCountObjectPtr<INTERP_KERNEL::Edge> >& edgesPtr):_pool(1)
-{
- _pool[0]._edges=edges;
- _pool[0]._edges_ptr=edgesPtr;
-}
-
-int VectorOfCellInfo::getPositionOf(double eps, const MEDCouplingUMesh *mesh) const
-{
- if(_pool.empty())
- throw INTERP_KERNEL::Exception("VectorOfCellSplitter::getPositionOf : empty !");
- if(_pool.size()==1)
- return 0;
- const MEDCouplingUMesh *zeMesh(_ze_mesh);
- if(!zeMesh)
- throw INTERP_KERNEL::Exception("VectorOfCellSplitter::getPositionOf : null aggregated mesh !");
- MEDCouplingAutoRefCountObjectPtr<DataArrayDouble> barys(mesh->getBarycenterAndOwner());
- return zeMesh->getCellContainingPoint(barys->begin(),eps);
-}
-
-void VectorOfCellInfo::setMeshAt(int pos, const MEDCouplingAutoRefCountObjectPtr<MEDCouplingUMesh>& mesh, int istart, int iend, const MEDCouplingAutoRefCountObjectPtr<MEDCouplingUMesh>& mesh1DInCase, const std::vector< std::vector<int> >& edges, const std::vector< std::vector< MEDCouplingAutoRefCountObjectPtr<INTERP_KERNEL::Edge> > >& edgePtrs)
-{
- get(pos);//to check pos
- bool isFast(pos==0 && _pool.size()==1);
- std::size_t sz(edges.size());
- // dealing with edges
- if(sz==1)
- _edge_info.push_back(EdgeInfo(istart,iend,mesh1DInCase));
- else
- _edge_info.push_back(EdgeInfo(istart,iend,pos,edgePtrs[0].back()));
- //
- std::vector<CellInfo> pool(_pool.size()-1+sz);
- for(int i=0;i<pos;i++)
- pool[i]=_pool[i];
- for(std::size_t j=0;j<sz;j++)
- pool[pos+j]=CellInfo(edges[j],edgePtrs[j]);
- for(int i=pos+1;i<(int)_pool.size();i++)
- pool[i+sz-1]=_pool[i];
- _pool=pool;
- //
- if(sz==2)
- updateEdgeInfo(pos,edgePtrs[0],edgePtrs[1]);
- //
- if(isFast)
- {
- _ze_mesh=mesh;
- return ;
- }
- //
- std::vector< MEDCouplingAutoRefCountObjectPtr<MEDCouplingUMesh> > ms;
- if(pos>0)
- {
- MEDCouplingAutoRefCountObjectPtr<MEDCouplingUMesh> elt(static_cast<MEDCouplingUMesh *>(_ze_mesh->buildPartOfMySelf2(0,pos,true)));
- ms.push_back(elt);
- }
- ms.push_back(mesh);
- if(pos<_ze_mesh->getNumberOfCells()-1)
- {
- MEDCouplingAutoRefCountObjectPtr<MEDCouplingUMesh> elt(static_cast<MEDCouplingUMesh *>(_ze_mesh->buildPartOfMySelf2(pos+1,_ze_mesh->getNumberOfCells(),true)));
- ms.push_back(elt);
- }
- std::vector< const MEDCouplingUMesh *> ms2(ms.size());
- for(std::size_t j=0;j<ms2.size();j++)
- ms2[j]=ms[j];
- _ze_mesh=MEDCouplingUMesh::MergeUMeshesOnSameCoords(ms2);
-}
-
-void VectorOfCellInfo::feedEdgeInfoAt(double eps, int pos, int offset, int neighbors[2]) const
-{
- _edge_info[getZePosOfEdgeGivenItsGlobalId(pos)].feedEdgeInfoAt(eps,_ze_mesh,offset,neighbors);
-}
-
-int VectorOfCellInfo::getZePosOfEdgeGivenItsGlobalId(int pos) const
-{
- if(pos<0)
- throw INTERP_KERNEL::Exception("VectorOfCellInfo::getZePosOfEdgeGivenItsGlobalId : invalid id ! Must be >=0 !");
- int ret(0);
- for(std::vector<EdgeInfo>::const_iterator it=_edge_info.begin();it!=_edge_info.end();it++,ret++)
- {
- if((*it).isInMyRange(pos))
- return ret;
- }
- throw INTERP_KERNEL::Exception("VectorOfCellInfo::getZePosOfEdgeGivenItsGlobalId : invalid id !");
-}
-
-void VectorOfCellInfo::updateEdgeInfo(int pos, const std::vector< MEDCouplingAutoRefCountObjectPtr<INTERP_KERNEL::Edge> >& newLeft, const std::vector< MEDCouplingAutoRefCountObjectPtr<INTERP_KERNEL::Edge> >& newRight)
-{
- get(pos);//to check;
- if(_edge_info.empty())
- return ;
- std::size_t sz(_edge_info.size()-1);
- for(std::size_t i=0;i<sz;i++)
- _edge_info[i].somethingHappendAt(pos,newLeft,newRight);
-}
-
-const CellInfo& VectorOfCellInfo::get(int pos) const
-{
- if(pos<0 || pos>=(int)_pool.size())
- throw INTERP_KERNEL::Exception("VectorOfCellSplitter::get const : invalid pos !");
- return _pool[pos];
-}
-
-CellInfo& VectorOfCellInfo::get(int pos)
-{
- if(pos<0 || pos>=(int)_pool.size())
- throw INTERP_KERNEL::Exception("VectorOfCellSplitter::get : invalid pos !");
- return _pool[pos];
-}
-
-/*!
- * Given :
- * - a \b closed set of edges ( \a allEdges and \a allEdgesPtr ) that defines the split descending 2D cell.
- * - \a splitMesh1D a split 2D curve mesh contained into 2D cell defined above.
- *
- * This method returns the 2D mesh and feeds \a idsLeftRight using offset.
- *
- * Algorithm : \a splitMesh1D is cut into contiguous parts. Each contiguous parts will build incrementally the output 2D cells.
- *
- * \param [in] allEdges a list of pairs (beginNode, endNode). Linked with \a allEdgesPtr to get the equation of edge.
- */
-MEDCouplingUMesh *BuildMesh2DCutInternal(double eps, const MEDCouplingUMesh *splitMesh1D, const std::vector<int>& allEdges, const std::vector< MEDCouplingAutoRefCountObjectPtr<INTERP_KERNEL::Edge> >& allEdgesPtr, int offset,
- MEDCouplingAutoRefCountObjectPtr<DataArrayInt>& idsLeftRight)
-{
- int nbCellsInSplitMesh1D(splitMesh1D->getNumberOfCells());
- if(nbCellsInSplitMesh1D==0)
- throw INTERP_KERNEL::Exception("BuildMesh2DCutInternal : internal error ! input 1D mesh must have at least one cell !");
- const int *cSplitPtr(splitMesh1D->getNodalConnectivity()->begin()),*ciSplitPtr(splitMesh1D->getNodalConnectivityIndex()->begin());
- std::size_t nb(allEdges.size()),jj;
- if(nb%2!=0)
- throw INTERP_KERNEL::Exception("BuildMesh2DCutFrom : internal error 2 !");
- std::vector<int> edge1Bis(nb*2);
- std::vector< MEDCouplingAutoRefCountObjectPtr<INTERP_KERNEL::Edge> > edge1BisPtr(nb*2);
- std::copy(allEdges.begin(),allEdges.end(),edge1Bis.begin());
- std::copy(allEdges.begin(),allEdges.end(),edge1Bis.begin()+nb);
- std::copy(allEdgesPtr.begin(),allEdgesPtr.end(),edge1BisPtr.begin());
- std::copy(allEdgesPtr.begin(),allEdgesPtr.end(),edge1BisPtr.begin()+nb);
- //
- idsLeftRight=DataArrayInt::New(); idsLeftRight->alloc(nbCellsInSplitMesh1D*2); idsLeftRight->fillWithValue(-2); idsLeftRight->rearrange(2);
- int *idsLeftRightPtr(idsLeftRight->getPointer());
- VectorOfCellInfo pool(edge1Bis,edge1BisPtr);
- for(int iStart=0;iStart<nbCellsInSplitMesh1D;)
- {// split [0:nbCellsInSplitMesh1D) in contiguous parts [iStart:iEnd)
- int iEnd(iStart);
- for(;iEnd<nbCellsInSplitMesh1D;)
- {
- for(jj=0;jj<nb && edge1Bis[2*jj+1]!=cSplitPtr[ciSplitPtr[iEnd]+2];jj++);
- if(jj!=nb)
- break;
- else
- iEnd++;
- }
- if(iEnd<nbCellsInSplitMesh1D)
- iEnd++;
- //
- MEDCouplingAutoRefCountObjectPtr<MEDCouplingUMesh> partOfSplitMesh1D(static_cast<MEDCouplingUMesh *>(splitMesh1D->buildPartOfMySelf2(iStart,iEnd,1,true)));
- int pos(pool.getPositionOf(eps,partOfSplitMesh1D));
- //
- MEDCouplingAutoRefCountObjectPtr<MEDCouplingUMesh>retTmp(MEDCouplingUMesh::New("",2));
- retTmp->setCoords(splitMesh1D->getCoords());
- retTmp->allocateCells();
-
- std::vector< std::vector<int> > out0;
- std::vector< std::vector< MEDCouplingAutoRefCountObjectPtr<INTERP_KERNEL::Edge> > > out1;
-
- BuildMesh2DCutInternal2(partOfSplitMesh1D,pool.getConnOf(pos),pool.getEdgePtrOf(pos),out0,out1);
- for(std::size_t cnt=0;cnt<out0.size();cnt++)
- AddCellInMesh2D(retTmp,out0[cnt],out1[cnt]);
- pool.setMeshAt(pos,retTmp,iStart,iEnd,partOfSplitMesh1D,out0,out1);
- //
- iStart=iEnd;
- }
- for(int mm=0;mm<nbCellsInSplitMesh1D;mm++)
- pool.feedEdgeInfoAt(eps,mm,offset,idsLeftRightPtr+2*mm);
- return pool.getZeMesh().retn();
-}
-
-MEDCouplingUMesh *BuildMesh2DCutFrom(double eps, int cellIdInMesh2D, const MEDCouplingUMesh *mesh2DDesc, const MEDCouplingUMesh *splitMesh1D,
- const int *descBg, const int *descEnd, const std::vector< std::vector<int> >& intersectEdge1, int offset,
- MEDCouplingAutoRefCountObjectPtr<DataArrayInt>& idsLeftRight)
-{
- const int *cdescPtr(mesh2DDesc->getNodalConnectivity()->begin()),*cidescPtr(mesh2DDesc->getNodalConnectivityIndex()->begin());
- //
- std::vector<int> allEdges;
- std::vector< MEDCouplingAutoRefCountObjectPtr<INTERP_KERNEL::Edge> > allEdgesPtr; // for each sub edge in splitMesh2D the uncut Edge object of the original mesh2D
- for(const int *it(descBg);it!=descEnd;it++) // for all edges in the descending connectivity of the 2D mesh in relative Fortran mode
- {
- int edgeId(std::abs(*it)-1);
- std::map< MEDCouplingAutoRefCountObjectPtr<INTERP_KERNEL::Node>,int> m;
- MEDCouplingAutoRefCountObjectPtr<INTERP_KERNEL::Edge> ee(MEDCouplingUMeshBuildQPFromEdge2((INTERP_KERNEL::NormalizedCellType)cdescPtr[cidescPtr[edgeId]],cdescPtr+cidescPtr[edgeId]+1,mesh2DDesc->getCoords()->begin(),m));
- const std::vector<int>& edge1(intersectEdge1[edgeId]);
- if(*it>0)
- allEdges.insert(allEdges.end(),edge1.begin(),edge1.end());
- else
- allEdges.insert(allEdges.end(),edge1.rbegin(),edge1.rend());
- std::size_t sz(edge1.size());
- for(std::size_t cnt=0;cnt<sz;cnt++)
- allEdgesPtr.push_back(ee);
- }
- //
- return BuildMesh2DCutInternal(eps,splitMesh1D,allEdges,allEdgesPtr,offset,idsLeftRight);
-}
-
-bool AreEdgeEqual(const double *coo2D, const INTERP_KERNEL::CellModel& typ1, const int *conn1, const INTERP_KERNEL::CellModel& typ2, const int *conn2, double eps)
-{
- if(!typ1.isQuadratic() && !typ2.isQuadratic())
- {//easy case comparison not
- return conn1[0]==conn2[0] && conn1[1]==conn2[1];
- }
- else if(typ1.isQuadratic() && typ2.isQuadratic())
- {
- bool status0(conn1[0]==conn2[0] && conn1[1]==conn2[1]);
- if(!status0)
- return false;
- if(conn1[2]==conn2[2])
- return true;
- const double *a(coo2D+2*conn1[2]),*b(coo2D+2*conn2[2]);
- double dist(sqrt((a[0]-b[0])*(a[0]-b[0])+(a[1]-b[1])*(a[1]-b[1])));
- return dist<eps;
- }
- else
- {//only one is quadratic
- bool status0(conn1[0]==conn2[0] && conn1[1]==conn2[1]);
- if(!status0)
- return false;
- const double *a(0),*bb(0),*be(0);
- if(typ1.isQuadratic())
- {
- a=coo2D+2*conn1[2]; bb=coo2D+2*conn2[0]; be=coo2D+2*conn2[1];
- }
- else
- {
- a=coo2D+2*conn2[2]; bb=coo2D+2*conn1[0]; be=coo2D+2*conn1[1];
- }
- double b[2]; b[0]=(be[0]+bb[0])/2.; b[1]=(be[1]+bb[1])/2.;
- double dist(sqrt((a[0]-b[0])*(a[0]-b[0])+(a[1]-b[1])*(a[1]-b[1])));
- return dist<eps;
- }
-}
-
-/*!
- * This method returns among the cellIds [ \a candidatesIn2DBg , \a candidatesIn2DEnd ) in \a mesh2DSplit those exactly sharing \a cellIdInMesh1DSplitRelative in \a mesh1DSplit.
- * \a mesh2DSplit and \a mesh1DSplit are expected to share the coordinates array.
- *
- * \param [in] cellIdInMesh1DSplitRelative is in Fortran mode using sign to specify direction.
- */
-int FindRightCandidateAmong(const MEDCouplingUMesh *mesh2DSplit, const int *candidatesIn2DBg, const int *candidatesIn2DEnd, const MEDCouplingUMesh *mesh1DSplit, int cellIdInMesh1DSplitRelative, double eps)
-{
- if(candidatesIn2DEnd==candidatesIn2DBg)
- throw INTERP_KERNEL::Exception("FindRightCandidateAmong : internal error 1 !");
- const double *coo(mesh2DSplit->getCoords()->begin());
- if(std::distance(candidatesIn2DBg,candidatesIn2DEnd)==1)
- return *candidatesIn2DBg;
- int edgeId(std::abs(cellIdInMesh1DSplitRelative)-1);
- MEDCouplingAutoRefCountObjectPtr<MEDCouplingUMesh> cur1D(static_cast<MEDCouplingUMesh *>(mesh1DSplit->buildPartOfMySelf(&edgeId,&edgeId+1,true)));
- if(cellIdInMesh1DSplitRelative<0)
- cur1D->changeOrientationOfCells();
- const int *c1D(cur1D->getNodalConnectivity()->begin());
- const INTERP_KERNEL::CellModel& ref1DType(INTERP_KERNEL::CellModel::GetCellModel((INTERP_KERNEL::NormalizedCellType)c1D[0]));
- for(const int *it=candidatesIn2DBg;it!=candidatesIn2DEnd;it++)
- {
- MEDCouplingAutoRefCountObjectPtr<MEDCouplingUMesh> cur2D(static_cast<MEDCouplingUMesh *>(mesh2DSplit->buildPartOfMySelf(it,it+1,true)));
- const int *c(cur2D->getNodalConnectivity()->begin()),*ci(cur2D->getNodalConnectivityIndex()->begin());
- const INTERP_KERNEL::CellModel &cm(INTERP_KERNEL::CellModel::GetCellModel((INTERP_KERNEL::NormalizedCellType)c[ci[0]]));
- unsigned sz(cm.getNumberOfSons2(c+ci[0]+1,ci[1]-ci[0]-1));
- INTERP_KERNEL::AutoPtr<int> tmpPtr(new int[ci[1]-ci[0]]);
- for(unsigned it2=0;it2<sz;it2++)
- {
- INTERP_KERNEL::NormalizedCellType typeOfSon;
- cm.fillSonCellNodalConnectivity2(it2,c+ci[0]+1,ci[1]-ci[0]-1,tmpPtr,typeOfSon);
- const INTERP_KERNEL::CellModel &curCM(INTERP_KERNEL::CellModel::GetCellModel(typeOfSon));
- if(AreEdgeEqual(coo,ref1DType,c1D+1,curCM,tmpPtr,eps))
- return *it;
- }
- }
- throw INTERP_KERNEL::Exception("FindRightCandidateAmong : internal error 2 ! Unable to find the edge among split cell !");
-}