+
+ //================================================================================
+ /*!
+ * \brief Return number of nodes in sonId-th son of a Dynamic() cell
+ */
+ //================================================================================
+
+ unsigned CellModel::getNumberOfNodesConstituentTheSon2(unsigned sonId, const int *nodalConn, int lgth) const
+ {
+ if(!isDynamic())
+ return getNumberOfNodesConstituentTheSon(sonId);
+
+ if(_dim==2)//polygon
+ {
+ if(_type==NORM_POLYGON)
+ return 2;
+ else
+ return 3;
+ }
+ else if(_dim==3)
+ {//polyedron
+ const int *where=nodalConn;
+ for(unsigned int i=0;i<sonId;i++)
+ {
+ where=std::find(where,nodalConn+lgth,-1);
+ where++;
+ }
+ const int *where2=std::find(where,nodalConn+lgth,-1);
+ return where2-where;
+ }
+ else
+ throw INTERP_KERNEL::Exception("CellModel::getNumberOfNodesConstituentTheSon2 : no sons on NORM_POLYL !");
+ }
+
+ /*!
+ * This method retrieves if cell1 represented by 'conn1' and cell2 represented by 'conn2'
+ * are equivalent by a permutation or not. This method expects to work on 1D or 2D (only mesh dimension where it is possible to have a spaceDim) strictly higher than meshDim.
+ * If not an exception will be thrown.
+ * @return True if two cells have same orientation, false if not.
+ */
+ bool CellModel::getOrientationStatus(unsigned lgth, const int *conn1, const int *conn2) const
+ {
+ if(_dim!=1 && _dim!=2)
+ throw INTERP_KERNEL::Exception("CellModel::getOrientationStatus : invalid dimension ! Must be 1 or 2 !");
+ if(!_quadratic)
+ {
+ std::vector<int> tmp(2*lgth);
+ std::vector<int>::iterator it=std::copy(conn1,conn1+lgth,tmp.begin());
+ std::copy(conn1,conn1+lgth,it);
+ it=std::search(tmp.begin(),tmp.end(),conn2,conn2+lgth);
+ if(it==tmp.begin())
+ return true;
+ if(it!=tmp.end())
+ return _dim!=1;
+ std::vector<int>::reverse_iterator it2=std::search(tmp.rbegin(),tmp.rend(),conn2,conn2+lgth);
+ if(it2!=tmp.rend())
+ return false;
+ throw INTERP_KERNEL::Exception("CellModel::getOrientationStatus : Request of orientation status of non equal connectively cells !");
+ }
+ else
+ {
+ if(_dim!=1)
+ {
+ std::vector<int> tmp(lgth);
+ std::vector<int>::iterator it=std::copy(conn1,conn1+lgth/2,tmp.begin());
+ std::copy(conn1,conn1+lgth/2,it);
+ it=std::search(tmp.begin(),tmp.end(),conn2,conn2+lgth/2);
+ int d=std::distance(tmp.begin(),it);
+ if(it==tmp.end())
+ return false;
+ it=std::copy(conn1+lgth/2,conn1+lgth,tmp.begin());
+ std::copy(conn1+lgth/2,conn1+lgth,it);
+ it=std::search(tmp.begin(),tmp.end(),conn2,conn2+lgth);
+ if(it==tmp.end())
+ return false;
+ int d2=std::distance(tmp.begin(),it);
+ return d==d2;
+ }
+ else
+ {
+ int p=(lgth+1)/2;
+ std::vector<int> tmp(2*p);
+ std::vector<int>::iterator it=std::copy(conn1,conn1+p,tmp.begin());
+ std::copy(conn1,conn1+p,it);
+ it=std::search(tmp.begin(),tmp.end(),conn2,conn2+p);
+ int d=std::distance(tmp.begin(),it);
+ if(it==tmp.end())
+ return false;
+ tmp.resize(2*p-2);
+ it=std::copy(conn1+p,conn1+lgth,tmp.begin());
+ std::copy(conn1+p,conn1+lgth,it);
+ it=std::search(tmp.begin(),tmp.end(),conn2+p,conn2+lgth);
+ if(it==tmp.end())
+ return false;
+ int d2=std::distance(tmp.begin(),it);
+ return d==d2;
+ }
+ }
+ }
+