+///@cond INTERNAL
+/**
+ * c, cI describe a wire mesh in 3D space, in local numbering
+ * startNode, endNode in global numbering
+ *\return true if the segment is indeed split
+ */
+bool MEDCouplingUMesh::OrderPointsAlongLine(const double * coo, mcIdType startNode, mcIdType endNode,
+ const mcIdType * c, const mcIdType * cI, const mcIdType *idsBg, const mcIdType *endBg,
+ std::vector<mcIdType> & pointIds, std::vector<mcIdType> & hitSegs)
+{
+ using namespace std;
+
+ const int SPACEDIM=3;
+ typedef pair<double, mcIdType> PairDI;
+ set< PairDI > x;
+ for (const mcIdType * it = idsBg; it != endBg; ++it)
+ {
+ assert(c[cI[*it]] == INTERP_KERNEL::NORM_SEG2);
+ mcIdType start = c[cI[*it]+1], end = c[cI[*it]+2];
+ x.insert(make_pair(coo[start*SPACEDIM], start)); // take only X coords
+ x.insert(make_pair(coo[end*SPACEDIM], end));
+ }
+
+ vector<PairDI> xx(x.begin(), x.end());
+ sort(xx.begin(),xx.end());
+ pointIds.reserve(xx.size());
+
+ // Keep what is inside [startNode, endNode]:
+ mcIdType go = 0;
+ for (vector<PairDI>::const_iterator it=xx.begin(); it != xx.end(); ++it)
+ {
+ const mcIdType idx = (*it).second;
+ if (!go)
+ {
+ if (idx == startNode) go = 1;
+ if (idx == endNode) go = 2;
+ if (go) pointIds.push_back(idx);
+ continue;
+ }
+ pointIds.push_back(idx);
+ if (idx == endNode || idx == startNode)
+ break;
+ }
+
+// vector<mcIdType> pointIds2(pointIds.size()+2);
+// copy(pointIds.begin(), pointIds.end(), pointIds2.data()+1);
+// pointIds2[0] = startNode;
+// pointIds2[pointIds2.size()-1] = endNode;
+
+ if (go == 2)
+ reverse(pointIds.begin(), pointIds.end());
+
+ // Now identify smaller segments that are not sub-divided - those won't need any further treatment:
+ for (const mcIdType * it = idsBg; it != endBg; ++it)
+ {
+ mcIdType start = c[cI[*it]+1], end = c[cI[*it]+2];
+ vector<mcIdType>::const_iterator itStart = find(pointIds.begin(), pointIds.end(), start);
+ if (itStart == pointIds.end()) continue;
+ vector<mcIdType>::const_iterator itEnd = find(pointIds.begin(), pointIds.end(), end);
+ if (itEnd == pointIds.end()) continue;
+ if (abs(distance(itEnd, itStart)) != 1) continue;
+ hitSegs.push_back(*it); // segment is undivided.
+ }
+
+ return (pointIds.size() > 2); // something else apart start and end node
+}
+
+void MEDCouplingUMesh::ReplaceEdgeInFace(const mcIdType * sIdxConn, const mcIdType * sIdxConnE, mcIdType startNode, mcIdType endNode,
+ const std::vector<mcIdType>& insidePoints, std::vector<mcIdType>& modifiedFace)
+{
+ using namespace std;
+ size_t dst = distance(sIdxConn, sIdxConnE);
+ modifiedFace.reserve(dst + insidePoints.size()-2);
+ modifiedFace.resize(dst);
+ copy(sIdxConn, sIdxConnE, modifiedFace.data());
+
+ vector<mcIdType>::iterator shortEnd = modifiedFace.begin()+dst;
+ vector<mcIdType>::iterator startPos = find(modifiedFace.begin(), shortEnd , startNode);
+ if (startPos == shortEnd)
+ throw INTERP_KERNEL::Exception("MEDCouplingUMesh::ReplaceEdgeInFace: internal error, should never happen!");
+ vector<mcIdType>::iterator endPos = find(modifiedFace.begin(),shortEnd, endNode);
+ if (endPos == shortEnd)
+ throw INTERP_KERNEL::Exception("MEDCouplingUMesh::ReplaceEdgeInFace: internal error, should never happen!");
+ size_t d = distance(startPos, endPos);
+ if (d == 1 || d == (1-dst)) // don't use modulo, for neg numbers, result is implementation defined ...
+ modifiedFace.insert(++startPos, ++insidePoints.begin(), --insidePoints.end()); // insidePoints also contains start and end node. Those don't need to be inserted.
+ else
+ modifiedFace.insert(++endPos, ++insidePoints.rbegin(), --insidePoints.rend());
+}
+
+///@endcond
+
+
+/*!
+ * \b WARNING this method is \b potentially \b non \b const (if returned array is not empty).
+ * \b WARNING this method lead to have a non geometric type sorted mesh (for MED file users) !
+ * This method performs a conformization of \b this.
+ *
+ * Only polyhedron cells are supported. You can call convertAllToPoly()
+ *
+ * This method expects that \b this has a meshDim equal 3 and spaceDim equal to 3 too.
+ * This method expects that all nodes in \a this are not closer than \a eps.
+ * If it is not the case you can invoke MEDCouplingUMesh::mergeNodes before calling this method.
+ *
+ * \b WARNING this method only works for 'partition-like' non-conformities. When joining adjacent faces, the set of all small faces must fit exactly into the
+ * neighboring bigger face. No real face intersection is actually computed.
+ *
+ * \param [in] eps the relative error to detect merged edges.
+ * \return DataArrayIdType * - The list of cellIds in \a this that have been subdivided. If empty, nothing changed in \a this (as if it were a const method). The array is a newly allocated array
+ * that the user is expected to deal with.
+ *
+ * \throw If \a this is not coherent.
+ * \throw If \a this has not spaceDim equal to 3.
+ * \throw If \a this has not meshDim equal to 3.
+ * \throw If the 'partition-like' condition described above is not respected.
+ * \sa MEDCouplingUMesh::mergeNodes, MEDCouplingUMesh::conformize2D, MEDCouplingUMesh::convertAllToPoly()
+ */
+DataArrayIdType *MEDCouplingUMesh::conformize3D(double eps)
+{
+ using namespace std;
+
+ static const int SPACEDIM=3;
+ checkConsistencyLight();
+ if(getSpaceDimension()!=3 || getMeshDimension()!=3)
+ throw INTERP_KERNEL::Exception("MEDCouplingUMesh::conformize3D : This method only works for meshes with spaceDim=3 and meshDim=3!");
+ if(_types.size() != 1 || *(_types.begin()) != INTERP_KERNEL::NORM_POLYHED)
+ throw INTERP_KERNEL::Exception("MEDCouplingUMesh::conformize3D : This method only works for polyhedrons! Call convertAllToPoly first.");
+
+ MCAuto<MEDCouplingSkyLineArray> connSla(MEDCouplingSkyLineArray::BuildFromPolyhedronConn(getNodalConnectivity(), getNodalConnectivityIndex()));
+ const double * coo(_coords->begin());
+ MCAuto<DataArrayIdType> ret(DataArrayIdType::New()); ret->alloc(0,1);
+
+ {
+ /*************************
+ * STEP 1 -- faces
+ *************************/
+ MCAuto<DataArrayIdType> descDNU(DataArrayIdType::New()),descIDNU(DataArrayIdType::New()),revDesc(DataArrayIdType::New()),revDescI(DataArrayIdType::New());
+ MCAuto<MEDCouplingUMesh> mDesc(buildDescendingConnectivity(descDNU,descIDNU,revDesc,revDescI));
+ const mcIdType *revDescIP(revDescI->getConstPointer()), *revDescP(revDesc->getConstPointer());
+ const mcIdType *cDesc(mDesc->getNodalConnectivity()->begin()),*cIDesc(mDesc->getNodalConnectivityIndex()->begin());
+ MCAuto<MEDCouplingSkyLineArray> connSlaDesc(MEDCouplingSkyLineArray::New(mDesc->getNodalConnectivityIndex(), mDesc->getNodalConnectivity()));
+
+ // Build BBTree
+ MCAuto<DataArrayDouble> bboxArr(mDesc->getBoundingBoxForBBTree(eps));
+ const double *bbox(bboxArr->begin()); getCoords()->begin();
+ mcIdType nDescCell=mDesc->getNumberOfCells();
+ BBTree<SPACEDIM,mcIdType> myTree(bbox,0,0,nDescCell,-eps);
+ // Surfaces - handle biggest first
+ MCAuto<MEDCouplingFieldDouble> surfF = mDesc->getMeasureField(true);
+ DataArrayDouble * surfs = surfF->getArray();
+ // Normal field
+ MCAuto<MEDCouplingFieldDouble> normalsF = mDesc->buildOrthogonalField();
+ DataArrayDouble * normals = normalsF->getArray();
+ const double * normalsP = normals->getConstPointer();
+
+ // Sort faces by decreasing surface:
+ vector< pair<double,mcIdType> > S;
+ for(mcIdType i=0;i < surfs->getNumberOfTuples();i++)
+ {
+ pair<double,mcIdType> p = make_pair(surfs->begin()[i], i);
+ S.push_back(p);
+ }
+ sort(S.rbegin(),S.rend()); // reverse sort
+ vector<bool> hit(nDescCell);
+ fill(hit.begin(), hit.end(), false);
+ vector<mcIdType> hitPoly; // the final result: which 3D cells have been modified.
+
+ for( vector<pair<double,mcIdType> >::const_iterator it = S.begin(); it != S.end(); it++)
+ {
+ mcIdType faceIdx = (*it).second;
+ if (hit[faceIdx]) continue;
+
+ vector<mcIdType> candidates, cands2;
+ myTree.getIntersectingElems(bbox+faceIdx*2*SPACEDIM,candidates);
+ // Keep only candidates whose normal matches the normal of current face
+ for(vector<mcIdType>::const_iterator it2=candidates.begin();it2!=candidates.end();it2++)
+ {
+ bool col = INTERP_KERNEL::isColinear3D(normalsP + faceIdx*SPACEDIM, normalsP + *(it2)*SPACEDIM, eps);
+ if (*it2 != faceIdx && col)
+ cands2.push_back(*it2);
+ }
+ if (!cands2.size())
+ continue;
+
+ // Now rotate, and match barycenters -- this is where we will bring Intersect2DMeshes later
+ INTERP_KERNEL::TranslationRotationMatrix rotation;
+ INTERP_KERNEL::TranslationRotationMatrix::Rotate3DTriangle(coo+SPACEDIM*(cDesc[cIDesc[faceIdx]+1]),
+ coo+SPACEDIM*(cDesc[cIDesc[faceIdx]+2]),
+ coo+SPACEDIM*(cDesc[cIDesc[faceIdx]+3]), rotation);
+
+ MCAuto<MEDCouplingUMesh> mPartRef(mDesc->buildPartOfMySelfSlice(faceIdx, faceIdx+1,1,false)); // false=zipCoords is called
+ MCAuto<MEDCouplingUMesh> mPartCand(mDesc->buildPartOfMySelf(&cands2[0], &cands2[0]+cands2.size(), false)); // false=zipCoords is called
+ double * cooPartRef(mPartRef->_coords->getPointer());
+ double * cooPartCand(mPartCand->_coords->getPointer());
+ for (mcIdType ii = 0; ii < mPartRef->_coords->getNumberOfTuples(); ii++)
+ rotation.transform_vector(cooPartRef+SPACEDIM*ii);
+ for (mcIdType ii = 0; ii < mPartCand->_coords->getNumberOfTuples(); ii++)
+ rotation.transform_vector(cooPartCand+SPACEDIM*ii);
+
+ // Localize faces in 2D thanks to barycenters
+ MCAuto<DataArrayDouble> baryPart = mPartCand->computeCellCenterOfMass();
+ vector<std::size_t> compo; compo.push_back(2);
+ MCAuto<DataArrayDouble> baryPartZ = baryPart->keepSelectedComponents(compo);
+ MCAuto<DataArrayIdType> idsGoodPlane = baryPartZ->findIdsInRange(-eps, +eps);
+ if (!idsGoodPlane->getNumberOfTuples())
+ continue;
+
+ baryPart = baryPart->selectByTupleId(*idsGoodPlane);
+
+ compo[0] = 0; compo.push_back(1);
+ MCAuto<DataArrayDouble> baryPartXY = baryPart->keepSelectedComponents(compo);
+ mPartRef->changeSpaceDimension(2,0.0);
+ MCAuto<DataArrayIdType> cc(DataArrayIdType::New()), ccI(DataArrayIdType::New());
+ mPartRef->getCellsContainingPoints(baryPartXY->begin(), baryPartXY->getNumberOfTuples(), eps, cc, ccI);
+
+ if (!cc->getNumberOfTuples())
+ continue;
+ MCAuto<DataArrayIdType> dsi = ccI->deltaShiftIndex();
+
+ {
+ MCAuto<DataArrayIdType> tmp = dsi->findIdsInRange(0, 2);
+ if (tmp->getNumberOfTuples() != dsi->getNumberOfTuples())
+ {
+ ostringstream oss;
+ oss << "MEDCouplingUMesh::conformize3D: Non expected non-conformity. Only simple (=partition-like) non-conformities are handled. Face #" << faceIdx << " violates this condition!";
+ throw INTERP_KERNEL::Exception(oss.str());
+ }
+ }
+
+ MCAuto<DataArrayIdType> ids = dsi->findIdsEqual(1);
+ // Boundary face:
+ if (!ids->getNumberOfTuples())
+ continue;
+
+ double checkSurf=0.0;
+ const mcIdType * idsGoodPlaneP(idsGoodPlane->begin());
+ for (const mcIdType * ii = ids->begin(); ii != ids->end(); ii++)
+ {
+ mcIdType faceIdx2 = cands2[idsGoodPlaneP[*ii]];
+ hit[faceIdx2] = true;
+ checkSurf += surfs->begin()[faceIdx2];
+ }
+ if (fabs(checkSurf - surfs->begin()[faceIdx]) > eps)
+ {
+ ostringstream oss;
+ oss << "MEDCouplingUMesh::conformize3D: Non expected non-conformity. Only simple (=partition-like) non-conformities are handled. Face #" << faceIdx << " violates this condition!";
+ throw INTERP_KERNEL::Exception(oss.str());
+ }
+
+ // For all polyhedrons using this face, replace connectivity:
+ vector<mcIdType> polyIndices, packsIds, facePack;
+ for (mcIdType ii=revDescIP[faceIdx]; ii < revDescIP[faceIdx+1]; ii++)
+ polyIndices.push_back(revDescP[ii]);
+ ret->pushBackValsSilent(polyIndices.data(),polyIndices.data()+polyIndices.size());
+
+ // Current face connectivity
+ const mcIdType * sIdxConn = cDesc + cIDesc[faceIdx] + 1;
+ const mcIdType * sIdxConnE = cDesc + cIDesc[faceIdx+1];
+ connSla->findPackIds(polyIndices, sIdxConn, sIdxConnE, packsIds);
+ // Deletion of old faces
+ mcIdType jj=0;
+ for (vector<mcIdType>::const_iterator it2=polyIndices.begin(); it2!=polyIndices.end(); ++it2, ++jj)
+ {
+ if (packsIds[jj] == -1)
+ // The below should never happen - if a face is used several times, with a different layout of the nodes
+ // it means that it is already conform, so it is *not* hit by the algorithm. The algorithm only hits
+ // faces which are actually used only once, by a single cell. This is different for edges below.
+ throw INTERP_KERNEL::Exception("MEDCouplingUMesh::conformize3D: Could not find face in connectivity! Internal error.");
+ else
+ connSla->deletePack(*it2, packsIds[jj]);
+ }
+ // Insertion of new faces:
+ for (const mcIdType * ii = ids->begin(); ii != ids->end(); ii++)
+ {
+ // Build pack from the face to insert:
+ mcIdType faceIdx2 = cands2[idsGoodPlane->getIJ(*ii,0)];
+ mcIdType facePack2Sz;
+ const mcIdType * facePack2 = connSlaDesc->getSimplePackSafePtr(faceIdx2, facePack2Sz); // contains the type!
+ // Insert it in all hit polyhedrons:
+ for (vector<mcIdType>::const_iterator it2=polyIndices.begin(); it2!=polyIndices.end(); ++it2)
+ connSla->pushBackPack(*it2, facePack2+1, facePack2+facePack2Sz); // without the type
+ }
+ }
+ } // end step1
+
+ // Set back modified connectivity
+ MCAuto<DataArrayIdType> cAuto; cAuto.takeRef(_nodal_connec);
+ MCAuto<DataArrayIdType> cIAuto; cIAuto.takeRef(_nodal_connec_index);
+ connSla->convertToPolyhedronConn(cAuto, cIAuto);
+
+ {
+ /************************
+ * STEP 2 -- edges
+ ************************/
+ // Now we have a face-conform mesh.
+
+ // Recompute descending
+ MCAuto<DataArrayIdType> desc(DataArrayIdType::New()),descI(DataArrayIdType::New()),revDesc(DataArrayIdType::New()),revDescI(DataArrayIdType::New());
+ // Rebuild desc connectivity with orientation this time!!
+ MCAuto<MEDCouplingUMesh> mDesc(buildDescendingConnectivity2(desc,descI,revDesc,revDescI));
+ const mcIdType *revDescIP(revDescI->getConstPointer()), *revDescP(revDesc->getConstPointer());
+ const mcIdType *descIP(descI->getConstPointer()), *descP(desc->getConstPointer());
+ const mcIdType *cDesc(mDesc->getNodalConnectivity()->begin()),*cIDesc(mDesc->getNodalConnectivityIndex()->begin());
+ MCAuto<DataArrayIdType> ciDeepC(mDesc->getNodalConnectivityIndex()->deepCopy());
+ MCAuto<DataArrayIdType> cDeepC(mDesc->getNodalConnectivity()->deepCopy());
+ MCAuto<MEDCouplingSkyLineArray> connSlaDesc(MEDCouplingSkyLineArray::New(ciDeepC, cDeepC));
+ MCAuto<DataArrayIdType> desc2(DataArrayIdType::New()),descI2(DataArrayIdType::New()),revDesc2(DataArrayIdType::New()),revDescI2(DataArrayIdType::New());
+ MCAuto<MEDCouplingUMesh> mDesc2 = mDesc->buildDescendingConnectivity(desc2,descI2,revDesc2,revDescI2);
+// std::cout << "writing!\n";
+// mDesc->writeVTK("/tmp/toto_desc_confInter.vtu");
+// mDesc2->writeVTK("/tmp/toto_desc2_confInter.vtu");
+ const mcIdType *revDescIP2(revDescI2->getConstPointer()), *revDescP2(revDesc2->getConstPointer());
+ const mcIdType *cDesc2(mDesc2->getNodalConnectivity()->begin()),*cIDesc2(mDesc2->getNodalConnectivityIndex()->begin());
+ MCAuto<DataArrayDouble> bboxArr(mDesc2->getBoundingBoxForBBTree(eps));
+ const double *bbox2(bboxArr->begin());
+ mcIdType nDesc2Cell=mDesc2->getNumberOfCells();
+ BBTree<SPACEDIM,mcIdType> myTree2(bbox2,0,0,nDesc2Cell,-eps);
+
+ // Edges - handle longest first
+ MCAuto<MEDCouplingFieldDouble> lenF = mDesc2->getMeasureField(true);
+ DataArrayDouble * lens = lenF->getArray();
+
+ // Sort edges by decreasing length:
+ vector<pair<double,mcIdType> > S;
+ for(mcIdType i=0;i < lens->getNumberOfTuples();i++)
+ {
+ pair<double,mcIdType> p = make_pair(lens->getIJ(i, 0), i);
+ S.push_back(p);
+ }
+ sort(S.rbegin(),S.rend()); // reverse sort
+
+ vector<bool> hit(nDesc2Cell);
+ fill(hit.begin(), hit.end(), false);
+
+ for( vector<pair<double,mcIdType> >::const_iterator it = S.begin(); it != S.end(); it++)
+ {
+ mcIdType eIdx = (*it).second;
+ if (hit[eIdx])
+ continue;
+
+ vector<mcIdType> candidates, cands2;
+ myTree2.getIntersectingElems(bbox2+eIdx*2*SPACEDIM,candidates);
+ // Keep only candidates colinear with current edge
+ double vCurr[3];
+ mcIdType start = cDesc2[cIDesc2[eIdx]+1], end = cDesc2[cIDesc2[eIdx]+2];
+ for (mcIdType i3=0; i3 < 3; i3++) // TODO: use fillSonCellNodalConnectivity2 or similar?
+ vCurr[i3] = coo[start*SPACEDIM+i3] - coo[end*SPACEDIM+i3];
+ for(vector<mcIdType>::const_iterator it2=candidates.begin();it2!=candidates.end();it2++)
+ {
+ double vOther[3];
+ mcIdType start2 = cDesc2[cIDesc2[*it2]+1], end2 = cDesc2[cIDesc2[*it2]+2];
+ for (mcIdType i3=0; i3 < 3; i3++)
+ vOther[i3] = coo[start2*SPACEDIM+i3] - coo[end2*SPACEDIM+i3];
+ bool col = INTERP_KERNEL::isColinear3D(vCurr, vOther, eps);
+ // Warning: different from faces: we need to keep eIdx in the final list of candidates because we need
+ // to have its nodes inside the sub mesh mPartCand below (needed in OrderPointsAlongLine())
+ if (col)
+ cands2.push_back(*it2);
+ }
+ if (cands2.size() == 1 && cands2[0] == eIdx) // see warning above
+ continue;
+
+ // Now rotate edges to bring them on Ox
+ mcIdType startNode = cDesc2[cIDesc2[eIdx]+1];
+ mcIdType endNode = cDesc2[cIDesc2[eIdx]+2];
+ INTERP_KERNEL::TranslationRotationMatrix rotation;
+ INTERP_KERNEL::TranslationRotationMatrix::Rotate3DBipoint(coo+SPACEDIM*startNode, coo+SPACEDIM*endNode, rotation);
+ MCAuto<MEDCouplingUMesh> mPartRef(mDesc2->buildPartOfMySelfSlice(eIdx, eIdx+1,1,false)); // false=zipCoords is called
+ MCAuto<MEDCouplingUMesh> mPartCand(mDesc2->buildPartOfMySelf(&cands2[0], &cands2[0]+cands2.size(), true)); // true=zipCoords is called
+ MCAuto<DataArrayIdType> nodeMap(mPartCand->zipCoordsTraducer());
+ mcIdType nbElemsNotM1;
+ {
+ MCAuto<DataArrayIdType> tmp(nodeMap->findIdsNotEqual(-1));
+ nbElemsNotM1 = tmp->getNbOfElems();
+ }
+ MCAuto<DataArrayIdType> nodeMapInv = nodeMap->invertArrayO2N2N2O(nbElemsNotM1);
+ double * cooPartRef(mPartRef->_coords->getPointer());
+ double * cooPartCand(mPartCand->_coords->getPointer());
+ for (mcIdType ii = 0; ii < mPartRef->_coords->getNumberOfTuples(); ii++)
+ rotation.transform_vector(cooPartRef+SPACEDIM*ii);
+ for (mcIdType ii = 0; ii < mPartCand->_coords->getNumberOfTuples(); ii++)
+ rotation.transform_vector(cooPartCand+SPACEDIM*ii);
+
+
+ // Eliminate all edges for which y or z is not null
+ MCAuto<DataArrayDouble> baryPart = mPartCand->computeCellCenterOfMass();
+ vector<std::size_t> compo; compo.push_back(1);
+ MCAuto<DataArrayDouble> baryPartY = baryPart->keepSelectedComponents(compo);
+ compo[0] = 2;
+ MCAuto<DataArrayDouble> baryPartZ = baryPart->keepSelectedComponents(compo);
+ MCAuto<DataArrayIdType> idsGoodLine1 = baryPartY->findIdsInRange(-eps, +eps);
+ MCAuto<DataArrayIdType> idsGoodLine2 = baryPartZ->findIdsInRange(-eps, +eps);
+ MCAuto<DataArrayIdType> idsGoodLine = idsGoodLine1->buildIntersection(idsGoodLine2);
+ if (!idsGoodLine->getNumberOfTuples())
+ continue;
+
+ // Now the ordering along the Ox axis:
+ std::vector<mcIdType> insidePoints, hitSegs;
+ bool isSplit = OrderPointsAlongLine(mPartCand->_coords->getConstPointer(), nodeMap->begin()[startNode], nodeMap->begin()[endNode],
+ mPartCand->getNodalConnectivity()->begin(), mPartCand->getNodalConnectivityIndex()->begin(),
+ idsGoodLine->begin(), idsGoodLine->end(),
+ /*out*/insidePoints, hitSegs);
+ // Optim: smaller segments completely included in eIdx and not split won't need any further treatment:
+ for (vector<mcIdType>::const_iterator its=hitSegs.begin(); its != hitSegs.end(); ++its)
+ hit[cands2[*its]] = true;
+
+ if (!isSplit) // current segment remains in one piece
+ continue;
+
+ // Get original node IDs in global coords array
+ for (std::vector<mcIdType>::iterator iit = insidePoints.begin(); iit!=insidePoints.end(); ++iit)
+ *iit = nodeMapInv->begin()[*iit];
+
+ vector<mcIdType> polyIndices, packsIds, facePack;
+ // For each face implying this edge
+ for (mcIdType ii=revDescIP2[eIdx]; ii < revDescIP2[eIdx+1]; ii++)
+ {
+ mcIdType faceIdx = revDescP2[ii];
+ // each cell where this face is involved connectivity will be modified:
+ ret->pushBackValsSilent(revDescP + revDescIP[faceIdx], revDescP + revDescIP[faceIdx+1]);
+
+ // Current face connectivity
+ const mcIdType * sIdxConn = cDesc + cIDesc[faceIdx] + 1;
+ const mcIdType * sIdxConnE = cDesc + cIDesc[faceIdx+1];
+
+ vector<mcIdType> modifiedFace;
+ ReplaceEdgeInFace(sIdxConn, sIdxConnE, startNode, endNode, insidePoints, /*out*/modifiedFace);
+ modifiedFace.insert(modifiedFace.begin(), INTERP_KERNEL::NORM_POLYGON);
+ connSlaDesc->replaceSimplePack(faceIdx, modifiedFace.data(), modifiedFace.data()+modifiedFace.size());
+ }
+ }
+
+ // Rebuild 3D connectivity from descending:
+ MCAuto<MEDCouplingSkyLineArray> newConn(MEDCouplingSkyLineArray::New());
+ MCAuto<DataArrayIdType> superIdx(DataArrayIdType::New()); superIdx->alloc(getNumberOfCells()+1); superIdx->fillWithValue(0);
+ MCAuto<DataArrayIdType> idx(DataArrayIdType::New()); idx->alloc(1); idx->fillWithValue(0);
+ MCAuto<DataArrayIdType> vals(DataArrayIdType::New()); vals->alloc(0);
+ newConn->set3(superIdx, idx, vals);
+ mcIdType nbCells=getNumberOfCells();
+ for(mcIdType ii = 0; ii < nbCells; ii++)
+ for (mcIdType jj=descIP[ii]; jj < descIP[ii+1]; jj++)
+ {
+ mcIdType sz, faceIdx = abs(descP[jj])-1;
+ bool orient = descP[jj]>0;
+ const mcIdType * p = connSlaDesc->getSimplePackSafePtr(faceIdx, sz);
+ if (orient)
+ newConn->pushBackPack(ii, p+1, p+sz); // +1 to skip type
+ else
+ {
+ vector<mcIdType> rev(sz-1);
+ for (mcIdType kk=0; kk<sz-1; kk++) rev[kk]=*(p+sz-kk-1);
+ newConn->pushBackPack(ii, rev.data(), rev.data()+sz-1);
+ }
+ }
+ // And finally:
+ newConn->convertToPolyhedronConn(cAuto, cIAuto);
+ } // end step2
+
+ ret = ret->buildUniqueNotSorted();
+ return ret.retn();
+}
+