+/*!
+ * This method builds the dual mesh of \a this and returns it.
+ *
+ * \return MEDCoupling1SGTUMesh * - newly object created to be managed by the caller.
+ * \throw If \a this is not a mesh containing only simplex cells.
+ * \throw If \a this is not correctly allocated (coordinates and connectivities have to be correctly set !).
+ * \throw If at least one node in \a this is orphan (without any simplex cell lying on it !)
+ */
+MEDCoupling1GTUMesh *MEDCoupling1SGTUMesh::computeDualMesh() const
+{
+ const INTERP_KERNEL::CellModel& cm(getCellModel());
+ if(!cm.isSimplex())
+ throw INTERP_KERNEL::Exception("MEDCoupling1SGTUMesh::computeDualMesh : this mesh is not a simplex mesh ! Please invoke simplexize of tetrahedrize on this before calling this method !");
+ switch(getMeshDimension())
+ {
+ case 3:
+ return computeDualMesh3D();
+ case 2:
+ return computeDualMesh2D();
+ default:
+ throw INTERP_KERNEL::Exception("MEDCoupling1SGTUMesh::computeDualMesh : meshdimension must be in [2,3] !");
+ }
+}
+
+/*!
+ * This method explode each NORM_HEXA8 cells in \a this into 6 NORM_QUAD4 cells and put the result into the MEDCoupling1SGTUMesh returned instance.
+ *
+ * \return MEDCoupling1SGTUMesh * - a newly allocated instances (to be managed by the caller) storing the result of the explosion.
+ * \throw If \a this is not a mesh containing only NORM_HEXA8 cells.
+ * \throw If \a this is not properly allocated.
+ */
+MEDCoupling1SGTUMesh *MEDCoupling1SGTUMesh::explodeEachHexa8To6Quad4() const
+{
+ const INTERP_KERNEL::CellModel& cm(getCellModel());
+ if(cm.getEnum()!=INTERP_KERNEL::NORM_HEXA8)
+ throw INTERP_KERNEL::Exception("MEDCoupling1SGTUMesh::explodeEachHexa8To6Quad4 : this method can be applied only on HEXA8 mesh !");
+ int nbHexa8(getNumberOfCells());
+ const int *inConnPtr(getNodalConnectivity()->begin());
+ MCAuto<MEDCoupling1SGTUMesh> ret(MEDCoupling1SGTUMesh::New(getName(),INTERP_KERNEL::NORM_QUAD4));
+ MCAuto<DataArrayInt> c(DataArrayInt::New()); c->alloc(nbHexa8*6*4,1);
+ int *cPtr(c->getPointer());
+ for(int i=0;i<nbHexa8;i++,inConnPtr+=8)
+ {
+ for(int j=0;j<6;j++,cPtr+=4)
+ cm.fillSonCellNodalConnectivity(j,inConnPtr,cPtr);
+ }
+ ret->setCoords(getCoords());
+ ret->setNodalConnectivity(c);
+ return ret.retn();
+}
+
+/*!
+ * This method starts from an unstructured mesh that hides in reality a cartesian mesh.
+ * If it is not the case, an exception will be thrown.
+ * This method returns three objects : The cartesian mesh geometrically equivalent to \a this (within a precision of \a eps) and a permutation of cells
+ * and a permutation of nodes.
+ *
+ * - this[cellPerm[i]]=ret[i]
+ *
+ * \param [out] cellPerm the permutation array of size \c this->getNumberOfCells()
+ * \param [out] nodePerm the permutation array of size \c this->getNumberOfNodes()
+ * \return MEDCouplingCMesh * - a newly allocated mesh that is the result of the structurization of \a this.
+ */
+MEDCouplingCMesh *MEDCoupling1SGTUMesh::structurizeMe(DataArrayInt *& cellPerm, DataArrayInt *& nodePerm, double eps) const
+{
+ checkConsistencyLight();
+ int spaceDim(getSpaceDimension()),meshDim(getMeshDimension()),nbNodes(getNumberOfNodes());
+ if(MEDCouplingStructuredMesh::GetGeoTypeGivenMeshDimension(meshDim)!=getCellModelEnum())
+ throw INTERP_KERNEL::Exception("MEDCoupling1SGTUMesh::structurizeMe : the unique geo type in this is not compatible with the geometric type regarding mesh dimension !");
+ MCAuto<MEDCouplingCMesh> cm(MEDCouplingCMesh::New());
+ for(int i=0;i<spaceDim;i++)
+ {
+ std::vector<int> tmp(1,i);
+ MCAuto<DataArrayDouble> elt(static_cast<DataArrayDouble*>(getCoords()->keepSelectedComponents(tmp)));
+ elt=elt->getDifferentValues(eps);
+ elt->sort(true);
+ cm->setCoordsAt(i,elt);
+ }
+ if(nbNodes!=cm->getNumberOfNodes())
+ throw INTERP_KERNEL::Exception("MEDCoupling1SGTUMesh::structurizeMe : considering the number of nodes after split per components in space this can't be a cartesian mesh ! Maybe your epsilon parameter is invalid ?");
+ try
+ { cm->copyTinyInfoFrom(this); }
+ catch(INTERP_KERNEL::Exception&) { }
+ MCAuto<MEDCouplingUMesh> um(cm->buildUnstructured()),self(buildUnstructured());
+ self->checkGeoEquivalWith(um,12,eps,cellPerm,nodePerm);
+ return cm.retn();
+}
+
+/// @cond INTERNAL
+
+bool UpdateHexa8Cell(int validAxis, int neighId, const int *validConnQuad4NeighSide, int *allFacesNodalConn, int *myNeighbours)
+{
+ static const int TAB[48]={
+ 0,1,2,3,4,5,6,7,//0
+ 4,7,6,5,0,3,2,1,//1
+ 0,3,7,4,1,2,6,5,//2
+ 4,0,3,7,5,1,2,6,//3
+ 5,1,0,4,6,2,3,7,//4
+ 3,7,4,0,2,6,5,1 //5
+ };
+ static const int TAB2[6]={0,0,3,3,3,3};
+ if(myNeighbours[validAxis]==neighId && allFacesNodalConn[4*validAxis+0]==validConnQuad4NeighSide[TAB2[validAxis]])
+ return true;
+ int oldAxis((int)std::distance(myNeighbours,std::find(myNeighbours,myNeighbours+6,neighId)));
+ std::size_t pos(std::distance(MEDCoupling1SGTUMesh::HEXA8_FACE_PAIRS,std::find(MEDCoupling1SGTUMesh::HEXA8_FACE_PAIRS,MEDCoupling1SGTUMesh::HEXA8_FACE_PAIRS+6,oldAxis)));
+ std::size_t pos0(pos/2),pos1(pos%2);
+ int oldAxisOpp(MEDCoupling1SGTUMesh::HEXA8_FACE_PAIRS[2*pos0+(pos1+1)%2]);
+ int oldConn[8],myConn2[8]={-1,-1,-1,-1,-1,-1,-1,-1},myConn[8],edgeConn[2],allFacesTmp[24],neighTmp[6];
+ oldConn[0]=allFacesNodalConn[0]; oldConn[1]=allFacesNodalConn[1]; oldConn[2]=allFacesNodalConn[2]; oldConn[3]=allFacesNodalConn[3];
+ oldConn[4]=allFacesNodalConn[4]; oldConn[5]=allFacesNodalConn[7]; oldConn[6]=allFacesNodalConn[6]; oldConn[7]=allFacesNodalConn[5];
+ const INTERP_KERNEL::CellModel& cm(INTERP_KERNEL::CellModel::GetCellModel(INTERP_KERNEL::NORM_HEXA8));
+ for(int i=0;i<4;i++)
+ myConn2[i]=validConnQuad4NeighSide[(4-i+TAB2[validAxis])%4];
+ for(int i=0;i<4;i++)
+ {
+ int nodeId(myConn2[i]);//the node id for which the opposite one will be found
+ bool found(false);
+ INTERP_KERNEL::NormalizedCellType typeOfSon;
+ for(int j=0;j<12 && !found;j++)
+ {
+ cm.fillSonEdgesNodalConnectivity3D(j,oldConn,-1,edgeConn,typeOfSon);
+ if(edgeConn[0]==nodeId || edgeConn[1]==nodeId)
+ {
+ if(std::find(allFacesNodalConn+4*oldAxisOpp,allFacesNodalConn+4*oldAxisOpp+4,edgeConn[0]==nodeId?edgeConn[1]:edgeConn[0])!=allFacesNodalConn+4*oldAxisOpp+4)
+ {
+ myConn2[i+4]=edgeConn[0]==nodeId?edgeConn[1]:edgeConn[0];
+ found=true;
+ }
+ }
+ }
+ if(!found)
+ throw INTERP_KERNEL::Exception("UpdateHexa8Cell : Internal Error !");
+ }
+ const int *myTab(TAB+8*validAxis);
+ for(int i=0;i<8;i++)
+ myConn[i]=myConn2[myTab[i]];
+ for(int i=0;i<6;i++)
+ {
+ cm.fillSonCellNodalConnectivity(i,myConn,allFacesTmp+4*i);
+ std::set<int> s(allFacesTmp+4*i,allFacesTmp+4*i+4);
+ bool found(false);
+ for(int j=0;j<6 && !found;j++)
+ {
+ std::set<int> s1(allFacesNodalConn+4*j,allFacesNodalConn+4*j+4);
+ if(s==s1)
+ {
+ neighTmp[i]=myNeighbours[j];
+ found=true;
+ }
+ }
+ if(!found)
+ throw INTERP_KERNEL::Exception("UpdateHexa8Cell : Internal Error #2 !");
+ }
+ std::copy(allFacesTmp,allFacesTmp+24,allFacesNodalConn);
+ std::copy(neighTmp,neighTmp+6,myNeighbours);
+ return false;
+}
+
+/// @endcond
+
+/*!
+ * This method expects the \a this contains NORM_HEXA8 cells only. This method will sort each cells in \a this so that their numbering was
+ * homogeneous. If it succeeds the result of MEDCouplingUMesh::tetrahedrize will return a conform mesh.
+ *
+ * \return DataArrayInt * - a newly allocated array (to be managed by the caller) containing renumbered cell ids.
+ *
+ * \throw If \a this is not a mesh containing only NORM_HEXA8 cells.
+ * \throw If \a this is not properly allocated.
+ * \sa MEDCouplingUMesh::tetrahedrize, MEDCouplingUMesh::simplexize.
+ */
+DataArrayInt *MEDCoupling1SGTUMesh::sortHexa8EachOther()
+{
+ MCAuto<MEDCoupling1SGTUMesh> quads(explodeEachHexa8To6Quad4());//checks that only hexa8
+ int nbHexa8(getNumberOfCells()),*cQuads(quads->getNodalConnectivity()->getPointer());
+ MCAuto<DataArrayInt> neighOfQuads(DataArrayInt::New()); neighOfQuads->alloc(nbHexa8*6,1); neighOfQuads->fillWithValue(-1);
+ int *ptNeigh(neighOfQuads->getPointer());
+ {//neighOfQuads tells for each face of each Quad8 which cell (if!=-1) is connected to this face.
+ MCAuto<MEDCouplingUMesh> quadsTmp(quads->buildUnstructured());
+ MCAuto<DataArrayInt> ccSafe,cciSafe;
+ DataArrayInt *cc(0),*cci(0);
+ quadsTmp->findCommonCells(3,0,cc,cci);
+ ccSafe=cc; cciSafe=cci;
+ const int *ccPtr(ccSafe->begin()),nbOfPair(cci->getNumberOfTuples()-1);
+ for(int i=0;i<nbOfPair;i++)
+ { ptNeigh[ccPtr[2*i+0]]=ccPtr[2*i+1]/6; ptNeigh[ccPtr[2*i+1]]=ccPtr[2*i+0]/6; }
+ }
+ MCAuto<DataArrayInt> ret(DataArrayInt::New()); ret->alloc(0,1);
+ std::vector<bool> fetched(nbHexa8,false);
+ std::vector<bool>::iterator it(std::find(fetched.begin(),fetched.end(),false));
+ while(it!=fetched.end())//it will turns as time as number of connected zones
+ {
+ int cellId((int)std::distance(fetched.begin(),it));//it is the seed of the connected zone.
+ std::set<int> s; s.insert(cellId);//s contains already organized.
+ while(!s.empty())
+ {
+ std::set<int> sNext;
+ for(std::set<int>::const_iterator it0=s.begin();it0!=s.end();it0++)
+ {
+ fetched[*it0]=true;
+ int *myNeighb(ptNeigh+6*(*it0));
+ for(int i=0;i<6;i++)
+ {
+ if(myNeighb[i]!=-1 && !fetched[myNeighb[i]])
+ {
+ std::size_t pos(std::distance(HEXA8_FACE_PAIRS,std::find(HEXA8_FACE_PAIRS,HEXA8_FACE_PAIRS+6,i)));
+ std::size_t pos0(pos/2),pos1(pos%2);
+ if(!UpdateHexa8Cell(HEXA8_FACE_PAIRS[2*pos0+(pos1+1)%2],*it0,cQuads+6*4*(*it0)+4*i,cQuads+6*4*myNeighb[i],ptNeigh+6*myNeighb[i]))
+ ret->pushBackSilent(myNeighb[i]);
+ fetched[myNeighb[i]]=true;
+ sNext.insert(myNeighb[i]);
+ }
+ }
+ }
+ s=sNext;
+ }
+ it=std::find(fetched.begin(),fetched.end(),false);
+ }
+ if(!ret->empty())
+ {
+ int *conn(getNodalConnectivity()->getPointer());
+ for(const int *pt=ret->begin();pt!=ret->end();pt++)
+ {
+ int cellId(*pt);
+ conn[8*cellId+0]=cQuads[24*cellId+0]; conn[8*cellId+1]=cQuads[24*cellId+1]; conn[8*cellId+2]=cQuads[24*cellId+2]; conn[8*cellId+3]=cQuads[24*cellId+3];
+ conn[8*cellId+4]=cQuads[24*cellId+4]; conn[8*cellId+5]=cQuads[24*cellId+7]; conn[8*cellId+6]=cQuads[24*cellId+6]; conn[8*cellId+7]=cQuads[24*cellId+5];
+ }
+ declareAsNew();
+ }
+ return ret.retn();
+}
+
+MEDCoupling1DGTUMesh *MEDCoupling1SGTUMesh::computeDualMesh3D() const
+{
+ static const int DUAL_TETRA_0[36]={
+ 4,1,0, 6,0,3, 7,3,1,
+ 4,0,1, 5,2,0, 8,1,2,
+ 6,3,0, 5,0,2, 9,2,3,
+ 7,1,3, 9,3,2, 8,2,1
+ };
+ static const int DUAL_TETRA_1[36]={
+ 8,4,10, 11,5,8, 10,7,11,
+ 9,4,8, 8,5,12, 12,6,9,
+ 10,4,9, 9,6,13, 13,7,10,
+ 12,5,11, 13,6,12, 11,7,13
+ };
+ static const int FACEID_NOT_SH_NODE[4]={2,3,1,0};
+ if(getCellModelEnum()!=INTERP_KERNEL::NORM_TETRA4)
+ throw INTERP_KERNEL::Exception("MEDCoupling1SGTUMesh::computeDualMesh3D : only TETRA4 supported !");
+ checkFullyDefined();
+ MCAuto<MEDCouplingUMesh> thisu(buildUnstructured());
+ MCAuto<DataArrayInt> revNodArr(DataArrayInt::New()),revNodIArr(DataArrayInt::New());
+ thisu->getReverseNodalConnectivity(revNodArr,revNodIArr);
+ const int *revNod(revNodArr->begin()),*revNodI(revNodIArr->begin()),*nodal(_conn->begin());
+ MCAuto<DataArrayInt> d1Arr(DataArrayInt::New()),di1Arr(DataArrayInt::New()),rd1Arr(DataArrayInt::New()),rdi1Arr(DataArrayInt::New());
+ MCAuto<MEDCouplingUMesh> edges(thisu->explode3DMeshTo1D(d1Arr,di1Arr,rd1Arr,rdi1Arr));
+ const int *d1(d1Arr->begin());
+ MCAuto<DataArrayInt> d2Arr(DataArrayInt::New()),di2Arr(DataArrayInt::New()),rd2Arr(DataArrayInt::New()),rdi2Arr(DataArrayInt::New());
+ MCAuto<MEDCouplingUMesh> faces(thisu->buildDescendingConnectivity(d2Arr,di2Arr,rd2Arr,rdi2Arr)); thisu=0;
+ const int *d2(d2Arr->begin()),*rdi2(rdi2Arr->begin());
+ MCAuto<DataArrayDouble> edgesBaryArr(edges->computeCellCenterOfMass()),facesBaryArr(faces->computeCellCenterOfMass()),baryArr(computeCellCenterOfMass());
+ const int nbOfNodes(getNumberOfNodes()),offset0(nbOfNodes+faces->getNumberOfCells()),offset1(offset0+edges->getNumberOfCells());
+ edges=0; faces=0;
+ std::vector<const DataArrayDouble *> v(4); v[0]=getCoords(); v[1]=facesBaryArr; v[2]=edgesBaryArr; v[3]=baryArr;
+ MCAuto<DataArrayDouble> zeArr(DataArrayDouble::Aggregate(v)); baryArr=0; edgesBaryArr=0; facesBaryArr=0;
+ std::string name("DualOf_"); name+=getName();
+ MCAuto<MEDCoupling1DGTUMesh> ret(MEDCoupling1DGTUMesh::New(name,INTERP_KERNEL::NORM_POLYHED)); ret->setCoords(zeArr);
+ MCAuto<DataArrayInt> cArr(DataArrayInt::New()),ciArr(DataArrayInt::New()); ciArr->alloc(nbOfNodes+1,1); ciArr->setIJ(0,0,0); cArr->alloc(0,1);
+ for(int i=0;i<nbOfNodes;i++,revNodI++)
+ {
+ int nbOfCellsSharingNode(revNodI[1]-revNodI[0]);
+ if(nbOfCellsSharingNode==0)
+ {
+ std::ostringstream oss; oss << "MEDCoupling1SGTUMesh::computeDualMesh3D : Node #" << i << " is orphan !";
+ throw INTERP_KERNEL::Exception(oss.str().c_str());
+ }
+ for(int j=0;j<nbOfCellsSharingNode;j++)
+ {
+ int curCellId(revNod[revNodI[0]+j]);
+ const int *connOfCurCell(nodal+4*curCellId);
+ std::size_t nodePosInCurCell(std::distance(connOfCurCell,std::find(connOfCurCell,connOfCurCell+4,i)));
+ if(j!=0) cArr->pushBackSilent(-1);
+ int tmp[14];
+ //
+ tmp[0]=d1[6*curCellId+DUAL_TETRA_0[nodePosInCurCell*9+0]-4]+offset0; tmp[1]=d2[4*curCellId+DUAL_TETRA_0[nodePosInCurCell*9+1]]+nbOfNodes;
+ tmp[2]=curCellId+offset1; tmp[3]=d2[4*curCellId+DUAL_TETRA_0[nodePosInCurCell*9+2]]+nbOfNodes;
+ tmp[4]=-1;
+ tmp[5]=d1[6*curCellId+DUAL_TETRA_0[nodePosInCurCell*9+3]-4]+offset0; tmp[6]=d2[4*curCellId+DUAL_TETRA_0[nodePosInCurCell*9+4]]+nbOfNodes;
+ tmp[7]=curCellId+offset1; tmp[8]=d2[4*curCellId+DUAL_TETRA_0[nodePosInCurCell*9+5]]+nbOfNodes;
+ tmp[9]=-1;
+ tmp[10]=d1[6*curCellId+DUAL_TETRA_0[nodePosInCurCell*9+6]-4]+offset0; tmp[11]=d2[4*curCellId+DUAL_TETRA_0[nodePosInCurCell*9+7]]+nbOfNodes;
+ tmp[12]=curCellId+offset1; tmp[13]=d2[4*curCellId+DUAL_TETRA_0[nodePosInCurCell*9+8]]+nbOfNodes;
+ cArr->insertAtTheEnd(tmp,tmp+14);
+ int kk(0);
+ for(int k=0;k<4;k++)
+ {
+ if(FACEID_NOT_SH_NODE[nodePosInCurCell]!=k)
+ {
+ const int *faceId(d2+4*curCellId+k);
+ if(rdi2[*faceId+1]-rdi2[*faceId]==1)
+ {
+ int tmp2[5]; tmp2[0]=-1; tmp2[1]=i;
+ tmp2[2]=d1[6*curCellId+DUAL_TETRA_1[9*nodePosInCurCell+3*kk+0]-8]+offset0;
+ tmp2[3]=d2[4*curCellId+DUAL_TETRA_1[9*nodePosInCurCell+3*kk+1]-4]+nbOfNodes;
+ tmp2[4]=d1[6*curCellId+DUAL_TETRA_1[9*nodePosInCurCell+3*kk+2]-8]+offset0;
+ cArr->insertAtTheEnd(tmp2,tmp2+5);
+ }
+ kk++;
+ }
+ }
+ }
+ ciArr->setIJ(i+1,0,cArr->getNumberOfTuples());
+ }
+ ret->setNodalConnectivity(cArr,ciArr);
+ return ret.retn();
+}
+
+MEDCoupling1DGTUMesh *MEDCoupling1SGTUMesh::computeDualMesh2D() const
+{
+ static const int DUAL_TRI_0[6]={0,2, 1,0, 2,1};
+ static const int DUAL_TRI_1[6]={-3,+5, +3,-4, +4,-5};
+ static const int FACEID_NOT_SH_NODE[3]={1,2,0};
+ if(getCellModelEnum()!=INTERP_KERNEL::NORM_TRI3)
+ throw INTERP_KERNEL::Exception("MEDCoupling1SGTUMesh::computeDualMesh2D : only TRI3 supported !");
+ checkFullyDefined();
+ MCAuto<MEDCouplingUMesh> thisu(buildUnstructured());
+ MCAuto<DataArrayInt> revNodArr(DataArrayInt::New()),revNodIArr(DataArrayInt::New());
+ thisu->getReverseNodalConnectivity(revNodArr,revNodIArr);
+ const int *revNod(revNodArr->begin()),*revNodI(revNodIArr->begin()),*nodal(_conn->begin());
+ MCAuto<DataArrayInt> d2Arr(DataArrayInt::New()),di2Arr(DataArrayInt::New()),rd2Arr(DataArrayInt::New()),rdi2Arr(DataArrayInt::New());
+ MCAuto<MEDCouplingUMesh> edges(thisu->buildDescendingConnectivity(d2Arr,di2Arr,rd2Arr,rdi2Arr)); thisu=0;
+ const int *d2(d2Arr->begin()),*rdi2(rdi2Arr->begin());
+ MCAuto<DataArrayDouble> edgesBaryArr(edges->computeCellCenterOfMass()),baryArr(computeCellCenterOfMass());
+ const int nbOfNodes(getNumberOfNodes()),offset0(nbOfNodes+edges->getNumberOfCells());
+ edges=0;
+ std::vector<const DataArrayDouble *> v(3); v[0]=getCoords(); v[1]=edgesBaryArr; v[2]=baryArr;
+ MCAuto<DataArrayDouble> zeArr(DataArrayDouble::Aggregate(v)); baryArr=0; edgesBaryArr=0;
+ std::string name("DualOf_"); name+=getName();
+ MCAuto<MEDCoupling1DGTUMesh> ret(MEDCoupling1DGTUMesh::New(name,INTERP_KERNEL::NORM_POLYGON)); ret->setCoords(zeArr);
+ MCAuto<DataArrayInt> cArr(DataArrayInt::New()),ciArr(DataArrayInt::New()); ciArr->alloc(nbOfNodes+1,1); ciArr->setIJ(0,0,0); cArr->alloc(0,1);
+ for(int i=0;i<nbOfNodes;i++,revNodI++)
+ {
+ int nbOfCellsSharingNode(revNodI[1]-revNodI[0]);
+ if(nbOfCellsSharingNode==0)
+ {
+ std::ostringstream oss; oss << "MEDCoupling1SGTUMesh::computeDualMesh2D : Node #" << i << " is orphan !";
+ throw INTERP_KERNEL::Exception(oss.str().c_str());
+ }
+ std::vector< std::vector<int> > polyg;
+ for(int j=0;j<nbOfCellsSharingNode;j++)
+ {
+ int curCellId(revNod[revNodI[0]+j]);
+ const int *connOfCurCell(nodal+3*curCellId);
+ std::size_t nodePosInCurCell(std::distance(connOfCurCell,std::find(connOfCurCell,connOfCurCell+4,i)));
+ std::vector<int> locV(3);
+ locV[0]=d2[3*curCellId+DUAL_TRI_0[2*nodePosInCurCell+0]]+nbOfNodes; locV[1]=curCellId+offset0; locV[2]=d2[3*curCellId+DUAL_TRI_0[2*nodePosInCurCell+1]]+nbOfNodes;
+ polyg.push_back(locV);
+ int kk(0);
+ for(int k=0;k<3;k++)
+ {
+ if(FACEID_NOT_SH_NODE[nodePosInCurCell]!=k)
+ {
+ const int *edgeId(d2+3*curCellId+k);
+ if(rdi2[*edgeId+1]-rdi2[*edgeId]==1)
+ {
+ std::vector<int> locV2(2);
+ int zeLocEdgeIdRel(DUAL_TRI_1[2*nodePosInCurCell+kk]);
+ if(zeLocEdgeIdRel>0)
+ { locV2[0]=d2[3*curCellId+zeLocEdgeIdRel-3]+nbOfNodes; locV2[1]=i; }
+ else
+ { locV2[0]=i; locV2[1]=d2[3*curCellId-zeLocEdgeIdRel-3]+nbOfNodes; }
+ polyg.push_back(locV2);
+ }
+ kk++;
+ }
+ }
+ }
+ std::vector<int> zePolyg(MEDCoupling1DGTUMesh::BuildAPolygonFromParts(polyg));
+ cArr->insertAtTheEnd(zePolyg.begin(),zePolyg.end());
+ ciArr->setIJ(i+1,0,cArr->getNumberOfTuples());
+ }
+ ret->setNodalConnectivity(cArr,ciArr);
+ return ret.retn();
+}
+
+/*!
+ * This method aggregate the bbox of each cell and put it into bbox
+ *
+ * \param [in] arcDetEps - a parameter specifying in case of 2D quadratic polygon cell the detection limit between linear and arc circle. (By default 1e-12)
+ * For all other cases this input parameter is ignored.
+ * \return DataArrayDouble * - newly created object (to be managed by the caller) \a this number of cells tuples and 2*spacedim components.
+ *
+ * \throw If \a this is not fully set (coordinates and connectivity).
+ * \throw If a cell in \a this has no valid nodeId.
+ */
+DataArrayDouble *MEDCoupling1SGTUMesh::getBoundingBoxForBBTree(double arcDetEps) const
+{
+ int spaceDim(getSpaceDimension()),nbOfCells(getNumberOfCells()),nbOfNodes(getNumberOfNodes()),nbOfNodesPerCell(getNumberOfNodesPerCell());
+ MCAuto<DataArrayDouble> ret(DataArrayDouble::New()); ret->alloc(nbOfCells,2*spaceDim);
+ double *bbox(ret->getPointer());
+ for(int i=0;i<nbOfCells*spaceDim;i++)
+ {
+ bbox[2*i]=std::numeric_limits<double>::max();
+ bbox[2*i+1]=-std::numeric_limits<double>::max();
+ }
+ const double *coordsPtr(_coords->getConstPointer());
+ const int *conn(_conn->getConstPointer());
+ for(int i=0;i<nbOfCells;i++)
+ {
+ int kk(0);
+ for(int j=0;j<nbOfNodesPerCell;j++,conn++)
+ {
+ int nodeId(*conn);
+ if(nodeId>=0 && nodeId<nbOfNodes)
+ {
+ for(int k=0;k<spaceDim;k++)
+ {
+ bbox[2*spaceDim*i+2*k]=std::min(bbox[2*spaceDim*i+2*k],coordsPtr[spaceDim*nodeId+k]);
+ bbox[2*spaceDim*i+2*k+1]=std::max(bbox[2*spaceDim*i+2*k+1],coordsPtr[spaceDim*nodeId+k]);
+ }
+ kk++;
+ }
+ }
+ if(kk==0)
+ {
+ std::ostringstream oss; oss << "MEDCoupling1SGTUMesh::getBoundingBoxForBBTree : cell #" << i << " contains no valid nodeId !";
+ throw INTERP_KERNEL::Exception(oss.str().c_str());
+ }
+ }
+ return ret.retn();
+}
+
+/*!
+ * Returns the cell field giving for each cell in \a this its diameter. Diameter means the max length of all possible SEG2 in the cell.
+ *
+ * \return a new instance of field containing the result. The returned instance has to be deallocated by the caller.
+ */
+MEDCouplingFieldDouble *MEDCoupling1SGTUMesh::computeDiameterField() const
+{
+ checkFullyDefined();
+ MCAuto<MEDCouplingFieldDouble> ret(MEDCouplingFieldDouble::New(ON_CELLS,ONE_TIME));
+ int nbCells(getNumberOfCells());
+ MCAuto<DataArrayDouble> arr(DataArrayDouble::New());
+ arr->alloc(nbCells,1);
+ INTERP_KERNEL::AutoCppPtr<INTERP_KERNEL::DiameterCalculator> dc(_cm->buildInstanceOfDiameterCalulator(getSpaceDimension()));
+ dc->computeFor1SGTUMeshFrmt(nbCells,_conn->begin(),getCoords()->begin(),arr->getPointer());
+ ret->setMesh(this);
+ ret->setArray(arr);
+ ret->setName("Diameter");
+ return ret.retn();
+}
+
+/*!
+ * This method invert orientation of all cells in \a this.
+ * After calling this method the absolute value of measure of cells in \a this are the same than before calling.
+ * This method only operates on the connectivity so coordinates are not touched at all.
+ */
+void MEDCoupling1SGTUMesh::invertOrientationOfAllCells()
+{
+ checkConsistencyOfConnectivity();
+ INTERP_KERNEL::AutoCppPtr<INTERP_KERNEL::OrientationInverter> oi(INTERP_KERNEL::OrientationInverter::BuildInstanceFrom(getCellModelEnum()));
+ int nbOfNodesPerCell((int)_cm->getNumberOfNodes()),nbCells(getNumberOfCells());
+ int *conn(_conn->getPointer());
+ for(int i=0;i<nbCells;i++)
+ oi->operate(conn+i*nbOfNodesPerCell,conn+(i+1)*nbOfNodesPerCell);
+ updateTime();
+}