//
// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
//
-// Author : Anthony Geay (CEA/DEN)
+// Author : Anthony Geay (EDF R&D)
#include "MEDCouplingUMesh.hxx"
#include "MEDCouplingCMesh.hxx"
double MEDCouplingUMesh::EPS_FOR_POLYH_ORIENTATION=1.e-14;
/// @cond INTERNAL
-const INTERP_KERNEL::NormalizedCellType MEDCouplingUMesh::MEDMEM_ORDER[N_MEDMEM_ORDER] = { INTERP_KERNEL::NORM_POINT1, INTERP_KERNEL::NORM_SEG2, INTERP_KERNEL::NORM_SEG3, INTERP_KERNEL::NORM_SEG4, INTERP_KERNEL::NORM_POLYL, INTERP_KERNEL::NORM_TRI3, INTERP_KERNEL::NORM_QUAD4, INTERP_KERNEL::NORM_TRI6, INTERP_KERNEL::NORM_TRI7, INTERP_KERNEL::NORM_QUAD8, INTERP_KERNEL::NORM_QUAD9, INTERP_KERNEL::NORM_POLYGON, INTERP_KERNEL::NORM_QPOLYG, INTERP_KERNEL::NORM_TETRA4, INTERP_KERNEL::NORM_PYRA5, INTERP_KERNEL::NORM_PENTA6, INTERP_KERNEL::NORM_HEXA8, INTERP_KERNEL::NORM_HEXGP12, INTERP_KERNEL::NORM_TETRA10, INTERP_KERNEL::NORM_PYRA13, INTERP_KERNEL::NORM_PENTA15, INTERP_KERNEL::NORM_HEXA20, INTERP_KERNEL::NORM_HEXA27, INTERP_KERNEL::NORM_POLYHED };
-const int MEDCouplingUMesh::MEDCOUPLING2VTKTYPETRADUCER[INTERP_KERNEL::NORM_MAXTYPE+1]={1,3,21,5,9,7,22,34,23,28,-1,-1,-1,-1,10,14,13,-1,12,-1,24,-1,16,27,-1,26,-1,29,-1,-1,25,42,36,4};
+const INTERP_KERNEL::NormalizedCellType MEDCouplingUMesh::MEDMEM_ORDER[N_MEDMEM_ORDER] = { INTERP_KERNEL::NORM_POINT1, INTERP_KERNEL::NORM_SEG2, INTERP_KERNEL::NORM_SEG3, INTERP_KERNEL::NORM_SEG4, INTERP_KERNEL::NORM_POLYL, INTERP_KERNEL::NORM_TRI3, INTERP_KERNEL::NORM_QUAD4, INTERP_KERNEL::NORM_TRI6, INTERP_KERNEL::NORM_TRI7, INTERP_KERNEL::NORM_QUAD8, INTERP_KERNEL::NORM_QUAD9, INTERP_KERNEL::NORM_POLYGON, INTERP_KERNEL::NORM_QPOLYG, INTERP_KERNEL::NORM_TETRA4, INTERP_KERNEL::NORM_PYRA5, INTERP_KERNEL::NORM_PENTA6, INTERP_KERNEL::NORM_HEXA8, INTERP_KERNEL::NORM_HEXGP12, INTERP_KERNEL::NORM_TETRA10, INTERP_KERNEL::NORM_PYRA13, INTERP_KERNEL::NORM_PENTA15, INTERP_KERNEL::NORM_PENTA18, INTERP_KERNEL::NORM_HEXA20, INTERP_KERNEL::NORM_HEXA27, INTERP_KERNEL::NORM_POLYHED };
+const int MEDCouplingUMesh::MEDCOUPLING2VTKTYPETRADUCER[INTERP_KERNEL::NORM_MAXTYPE+1]={1,3,21,5,9,7,22,34,23,28,-1,-1,-1,-1,10,14,13,-1,12,-1,24,-1,16,27,-1,26,-1,29,32,-1,25,42,36,4};
/// @endcond
MEDCouplingUMesh *MEDCouplingUMesh::New()
oss << ", whereas other mesh dimension is set equal to " << otherOnSameCoordsThanThis.getMeshDimension() << " !";
throw INTERP_KERNEL::Exception(oss.str());
}
- int nbOfCellsToModify=(int)std::distance(cellIdsBg,cellIdsEnd);
+ std::size_t nbOfCellsToModify(std::distance(cellIdsBg,cellIdsEnd));
if(nbOfCellsToModify!=otherOnSameCoordsThanThis.getNumberOfCells())
{
std::ostringstream oss; oss << "MEDCouplingUMesh::setPartOfMySelf : cells ids length (" << nbOfCellsToModify << ") do not match the number of cells of other mesh (" << otherOnSameCoordsThanThis.getNumberOfCells() << ") !";
throw INTERP_KERNEL::Exception(oss.str());
}
- int nbOfCells=getNumberOfCells();
- bool easyAssign=true;
- const int *connI=_nodal_connec_index->getConstPointer();
- const int *connIOther=otherOnSameCoordsThanThis._nodal_connec_index->getConstPointer();
+ std::size_t nbOfCells(getNumberOfCells());
+ bool easyAssign(true);
+ const int *connI(_nodal_connec_index->begin());
+ const int *connIOther=otherOnSameCoordsThanThis._nodal_connec_index->begin();
for(const int *it=cellIdsBg;it!=cellIdsEnd && easyAssign;it++,connIOther++)
{
- if(*it>=0 && *it<nbOfCells)
+ if(*it>=0 && *it<(int)nbOfCells)
{
easyAssign=(connIOther[1]-connIOther[0])==(connI[*it+1]-connI[*it]);
}
throw INTERP_KERNEL::Exception(oss.str());
}
int nbOfCellsToModify=DataArray::GetNumberOfItemGivenBESRelative(start,end,step,"MEDCouplingUMesh::setPartOfMySelfSlice : ");
- if(nbOfCellsToModify!=otherOnSameCoordsThanThis.getNumberOfCells())
+ if(nbOfCellsToModify!=(int)otherOnSameCoordsThanThis.getNumberOfCells())
{
std::ostringstream oss; oss << "MEDCouplingUMesh::setPartOfMySelfSlice : cells ids length (" << nbOfCellsToModify << ") do not match the number of cells of other mesh (" << otherOnSameCoordsThanThis.getNumberOfCells() << ") !";
throw INTERP_KERNEL::Exception(oss.str());
// Connex zone without the crack (to compute the next seed really)
int dnu;
DAInt connexCheck = MEDCouplingUMesh::ComputeSpreadZoneGraduallyFromSeed(&seed, &seed+1, neighInit00,neighIInit00, -1, dnu);
- int cnt = 0;
+ std::size_t cnt(0);
for (int * ptr = connexCheck->getPointer(); cnt < connexCheck->getNumberOfTuples(); ptr++, cnt++)
hitCells->setIJ(*ptr,0,1);
// Connex zone WITH the crack (to identify cells lying on either part of the crack)
* \return INTERP_KERNEL::NormalizedCellType - enumeration item describing the cell type.
* \throw If \a cellId is invalid. Valid range is [0, \a this->getNumberOfCells() ).
*/
-INTERP_KERNEL::NormalizedCellType MEDCouplingUMesh::getTypeOfCell(int cellId) const
+INTERP_KERNEL::NormalizedCellType MEDCouplingUMesh::getTypeOfCell(std::size_t cellId) const
{
- const int *ptI=_nodal_connec_index->getConstPointer();
- const int *pt=_nodal_connec->getConstPointer();
- if(cellId>=0 && cellId<(int)_nodal_connec_index->getNbOfElems()-1)
+ const int *ptI(_nodal_connec_index->begin()),*pt(_nodal_connec->begin());
+ if(cellId<_nodal_connec_index->getNbOfElems()-1)
return (INTERP_KERNEL::NormalizedCellType) pt[ptI[cellId]];
else
{
/*!
* Returns nb of cells having the geometric type \a type. No throw if no cells in \a this has the geometric type \a type.
*/
-int MEDCouplingUMesh::getNumberOfCellsWithType(INTERP_KERNEL::NormalizedCellType type) const
+std::size_t MEDCouplingUMesh::getNumberOfCellsWithType(INTERP_KERNEL::NormalizedCellType type) const
{
- const int *ptI=_nodal_connec_index->getConstPointer();
- const int *pt=_nodal_connec->getConstPointer();
- int nbOfCells=getNumberOfCells();
- int ret=0;
- for(int i=0;i<nbOfCells;i++)
+ const int *ptI(_nodal_connec_index->begin()),*pt(_nodal_connec->begin());
+ std::size_t nbOfCells(getNumberOfCells()),ret(0);
+ for(std::size_t i=0;i<nbOfCells;i++)
if((INTERP_KERNEL::NormalizedCellType) pt[ptI[i]]==type)
ret++;
return ret;
* cleared before the appending.
* \throw If \a cellId is invalid. Valid range is [0, \a this->getNumberOfCells() ).
*/
-void MEDCouplingUMesh::getNodeIdsOfCell(int cellId, std::vector<int>& conn) const
+void MEDCouplingUMesh::getNodeIdsOfCell(std::size_t cellId, std::vector<int>& conn) const
{
- const int *ptI=_nodal_connec_index->getConstPointer();
- const int *pt=_nodal_connec->getConstPointer();
+ const int *ptI(_nodal_connec_index->begin()),*pt(_nodal_connec->begin());
for(const int *w=pt+ptI[cellId]+1;w!=pt+ptI[cellId+1];w++)
if(*w>=0)
conn.push_back(*w);
* \return int - the number of cells in \a this mesh.
* \throw If the nodal connectivity of cells is not defined.
*/
-int MEDCouplingUMesh::getNumberOfCells() const
+std::size_t MEDCouplingUMesh::getNumberOfCells() const
{
if(_nodal_connec_index)
return _nodal_connec_index->getNumberOfTuples()-1;
std::vector<std::vector<int> > res;
buildSubCellsFromCut(cut3DSurf,desc2->begin(),descIndx2->begin(),mDesc1->getCoords()->begin(),eps,res);
std::size_t sz(res.size());
- if((int)res.size()==mDesc1->getNumberOfCells() && sameNbNodes)
+ if(res.size()==mDesc1->getNumberOfCells() && sameNbNodes)
throw INTERP_KERNEL::Exception("MEDCouplingUMesh::clipSingle3DCellByPlane : cell is not clipped !");
for(std::size_t i=0;i<sz;i++)
{
MCAuto<MEDCouplingFieldDouble> f=buildDirectionVectorField();
const double *fPtr=f->getArray()->getConstPointer();
double tmp[3];
- for(int i=0;i<getNumberOfCells();i++)
+ for(std::size_t i=0;i<getNumberOfCells();i++)
{
const double *tmp1=fPtr+3*i;
tmp[0]=tmp1[1]*v[2]-tmp1[2]*v[1];
DataArrayDouble *MEDCouplingUMesh::getBoundingBoxForBBTree2DQuadratic(double arcDetEps) const
{
checkFullyDefined();
+ INTERP_KERNEL::QuadraticPlanarArcDetectionPrecision arcPrec(arcDetEps);
+
int spaceDim(getSpaceDimension()),mDim(getMeshDimension()),nbOfCells(getNumberOfCells());
if(spaceDim!=2 || mDim!=2)
throw INTERP_KERNEL::Exception("MEDCouplingUMesh::getBoundingBoxForBBTree2DQuadratic : This method should be applied on mesh with mesh dimension equal to 2 and space dimension also equal to 2!");
{
const INTERP_KERNEL::CellModel& cm(INTERP_KERNEL::CellModel::GetCellModel((INTERP_KERNEL::NormalizedCellType)conn[*connI]));
int sz(connI[1]-connI[0]-1);
- INTERP_KERNEL::QUADRATIC_PLANAR::_arc_detection_precision=arcDetEps;
std::vector<INTERP_KERNEL::Node *> nodes(sz);
INTERP_KERNEL::QuadraticPolygon *pol(0);
for(int j=0;j<sz;j++)
int spaceDim(getSpaceDimension()),mDim(getMeshDimension()),nbOfCells(getNumberOfCells());
if(spaceDim!=2 || mDim!=1)
throw INTERP_KERNEL::Exception("MEDCouplingUMesh::getBoundingBoxForBBTree1DQuadratic : This method should be applied on mesh with mesh dimension equal to 1 and space dimension also equal to 2!");
+ INTERP_KERNEL::QuadraticPlanarArcDetectionPrecision arcPrec(arcDetEps);
MCAuto<DataArrayDouble> ret(DataArrayDouble::New()); ret->alloc(nbOfCells,2*spaceDim);
double *bbox(ret->getPointer());
const double *coords(_coords->begin());
{
const INTERP_KERNEL::CellModel& cm(INTERP_KERNEL::CellModel::GetCellModel((INTERP_KERNEL::NormalizedCellType)conn[*connI]));
int sz(connI[1]-connI[0]-1);
- INTERP_KERNEL::QUADRATIC_PLANAR::_arc_detection_precision=arcDetEps;
std::vector<INTERP_KERNEL::Node *> nodes(sz);
INTERP_KERNEL::Edge *edge(0);
for(int j=0;j<sz;j++)
previousArrI=*arrIPtr;
*arrIPtr=(int)arrOut.size();
}
- if(arr->getNumberOfTuples()==(int)arrOut.size())
+ if(arr->getNumberOfTuples()==arrOut.size())
return false;
arr->alloc((int)arrOut.size(),1);
std::copy(arrOut.begin(),arrOut.end(),arr->getPointer());