+ for(std::map<mcIdType, INTERP_KERNEL::NodeWithUsage >::const_iterator it2=mapp2.begin();it2!=mapp2.end();it2++)
+ {
+ if((*it2).second.second == INTERP_KERNEL::USAGE_LINEAR)
+ mapp[(*it2).second.first]=(*it2).first;
+ ((*it2).second.first)->decrRef();
+ }
+ return ret;
+ }
+
+ INTERP_KERNEL::QuadraticPolygon *MEDCouplingUMeshBuildQPFromMeshWithTree(const MEDCouplingUMesh *mDesc, const std::vector<mcIdType>& candidates,
+ std::map<INTERP_KERNEL::Node *,mcIdType>& mapp,
+ const BBTreePts<2,mcIdType> & nodeTree,
+ const std::map<mcIdType, INTERP_KERNEL::Node *>& mapRev)
+ {
+ mapp.clear();
+ std::map<mcIdType, INTERP_KERNEL::NodeWithUsage > mapp2; // the last var is a flag specifying if node is an extreme node of the seg (LINEAR) or only a middle for SEG3 (QUADRATIC_ONLY).
+ const double *coo=mDesc->getCoords()->getConstPointer();
+ const mcIdType *c=mDesc->getNodalConnectivity()->getConstPointer();
+ const mcIdType *cI=mDesc->getNodalConnectivityIndex()->getConstPointer();
+ std::set<mcIdType> s;
+ for(std::vector<mcIdType>::const_iterator it=candidates.begin();it!=candidates.end();it++)
+ s.insert(c+cI[*it]+1,c+cI[(*it)+1]);
+ for(std::set<mcIdType>::const_iterator it2=s.begin();it2!=s.end();it2++)
+ {
+ INTERP_KERNEL::Node *n;
+ // Look for a potential node to merge
+ std::vector<mcIdType> candNode;
+ nodeTree.getElementsAroundPoint(coo+2*(*it2), candNode);
+ if (candNode.size() > 2)
+ throw INTERP_KERNEL::Exception("MEDCouplingUMesh::MEDCouplingUMeshBuildQPFromMeshWithTree(): some nodes are not properly merged (within eps) in input mesh!");
+ bool node_created=false;
+ if (candNode.size())
+ {
+ auto itt=mapRev.find(candNode[0]);
+ if (itt != mapRev.end()) // we might hit a node which is in the coords array but not used in the connectivity in which case it won't be in the revMap
+ {
+ node_created=true;
+ n = (*itt).second;
+ n->incrRef();
+ }
+ }
+ if(!node_created)
+ n = new INTERP_KERNEL::Node(coo[2*(*it2)],coo[2*(*it2)+1]);
+ mapp2[*it2]=INTERP_KERNEL::NodeWithUsage(n,INTERP_KERNEL::USAGE_UNKNOWN);
+ }
+ INTERP_KERNEL::QuadraticPolygon *ret=new INTERP_KERNEL::QuadraticPolygon;
+ for(std::vector<mcIdType>::const_iterator it=candidates.begin();it!=candidates.end();it++)