using namespace MEDCoupling;
MEDCouplingSkyLineArray::MEDCouplingSkyLineArray():
- _index( DataArrayInt::New() ), _values( DataArrayInt::New() ), _super_index( DataArrayInt::New() )
+ _super_index( DataArrayInt::New() ), _index( DataArrayInt::New() ), _values( DataArrayInt::New() )
{
}
const int * cP(c->begin()), * cIP(cI->begin());
int prev = -1;
- if (c->getNbOfElems() != *(cI->end()-1))
+ if ((int)c->getNbOfElems() != *(cI->end()-1))
throw INTERP_KERNEL::Exception("MEDCouplingSkyLineArray::BuildFromDynamicConn: misformatted connectivity (wrong nb of tuples)!");
- for (int i=0; i < cI->getNbOfElems(); i++)
+ for (std::size_t i=0; i < cI->getNbOfElems(); i++)
{
int j = cIP[i];
if (cIP[i] < prev)
superIdx.push_back(0);
idx.push_back(0);
vals.resize(c->getNbOfElems()); // too much because of the type and the -1, but still better than push_back().
- for (int i=0; i < cI->getNbOfElems()-1; i++)
+ for (std::size_t i=0; i < cI->getNbOfElems()-1; i++)
{
int start = cIP[i]+1, end = cIP[i+1];
int * work = vals.data() + cnt;
c->alloc(sz, 1);
int * cVecP(c->getPointer());
- for (int i=0; i < _super_index->getNbOfElems()-1; i++)
+ for ( std::size_t i=0; i < _super_index->getNbOfElems()-1; i++)
{
cIVecP[i]= cnt;
int endId = siP[i+1];
DataArrayInt* MEDCouplingSkyLineArray::getSuperIndexArray() const
{
- return ((MEDCouplingSkyLineArray*)this)->_super_index;
+ return const_cast<MEDCouplingSkyLineArray*>(this)->_super_index;
}
DataArrayInt* MEDCouplingSkyLineArray::getIndexArray() const
{
- return ((MEDCouplingSkyLineArray*)this)->_index;
+ return const_cast<MEDCouplingSkyLineArray*>(this)->_index;
}
DataArrayInt* MEDCouplingSkyLineArray::getValuesArray() const
{
- return ((MEDCouplingSkyLineArray*)this)->_values;
+ return const_cast<MEDCouplingSkyLineArray*>(this)->_values;
}
void MEDCouplingSkyLineArray::checkSuperIndex(const std::string& func) const
void MEDCouplingSkyLineArray::validSuperIndex(const std::string& func, int superIndex) const
{
- if(superIndex < 0 || superIndex >= _super_index->getNbOfElems())
+ if(superIndex < 0 || superIndex >= (int)_super_index->getNbOfElems())
{
std::ostringstream oss;
oss << "MEDCouplingSkyLineArray::" << func << ": invalid super index!";
void MEDCouplingSkyLineArray::validIndex(const std::string& func, int idx) const
{
- if(idx < 0 || idx >= _index->getNbOfElems())
+ if(idx < 0 || idx >= (int)_index->getNbOfElems())
{
std::ostringstream oss;
oss << "MEDCouplingSkyLineArray::" << func << ": invalid index!";
{
validSuperIndex(func, superIndex);
int idx = _super_index->begin()[superIndex] + index;
- if(idx < 0 || idx >= _index->getNbOfElems())
+ if(idx < 0 || idx >= (int)_index->getNbOfElems())
{
std::ostringstream oss;
oss << "MEDCouplingSkyLineArray::" << func << ": invalid index!";
*/
void MEDCouplingSkyLineArray::getSimplePackSafe(const int absolutePackId, std::vector<int> & pack) const
{
- if(absolutePackId < 0 || absolutePackId >= _index->getNbOfElems())
+ if(absolutePackId < 0 || absolutePackId >= (int)_index->getNbOfElems())
throw INTERP_KERNEL::Exception("MEDCouplingSkyLineArray::getPackSafe: invalid index!");
const int * iP(_index->begin()), *vP(_values->begin());
int sz = iP[absolutePackId+1]-iP[absolutePackId];
*/
const int * MEDCouplingSkyLineArray::getSimplePackSafePtr(const int absolutePackId, int & packSize) const
{
- if(absolutePackId < 0 || absolutePackId >= _index->getNbOfElems())
+ if(absolutePackId < 0 || absolutePackId >= (int)_index->getNbOfElems())
throw INTERP_KERNEL::Exception("MEDCouplingSkyLineArray::getPackSafe: invalid index!");
const int * iP(_index->begin()), *vP(_values->begin());
packSize = iP[absolutePackId+1]-iP[absolutePackId];
iP[ii] -= (end-start);
// _super_index
- for(int ii = superIdx+1; ii < _super_index->getNbOfElems(); ii++)
+ for(int ii = superIdx+1; ii < (int)_super_index->getNbOfElems(); ii++)
(siP[ii])--;
}
iP[ii] += sz;
// _super_index
- for(int ii = superIdx+1; ii < _super_index->getNbOfElems(); ii++)
+ for(int ii = superIdx+1; ii < (int)_super_index->getNbOfElems(); ii++)
(siP[ii])++;
}
copy(packBg, packEnd, _values->getPointer()+start);
// _index
- for(int ii = idx+1; ii < _index->getNbOfElems(); ii++)
+ for(int ii = idx+1; ii < (int)_index->getNbOfElems(); ii++)
iP[ii] += deltaSz;
}
copy(packBg, packEnd, _values->getPointer()+start);
// _index
- for(int ii = siP[superIdx]+idx+1; ii < _index->getNbOfElems(); ii++)
+ for(int ii = siP[superIdx]+idx+1; ii < (int)_index->getNbOfElems(); ii++)
iP[ii] += deltaSz;
}
throw INTERP_KERNEL::Exception("MEDCouplingUMesh::buildSubCellsFromCut works only with single cell presently !");
for(int i=0;i<nbOfCells;i++)
{
- int offset(descIndx[i]),nbOfFaces(descIndx[i+1]-offset),start(-1),end(-1);
+ int offset(descIndx[i]),nbOfFaces(descIndx[i+1]-offset);
for(int j=0;j<nbOfFaces;j++)
{
const std::pair<int,int>& p=cut3DSurf[desc[offset+j]];
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.");
- int *c(getNodalConnectivity()->getPointer()),*cI(getNodalConnectivityIndex()->getPointer());
MCAuto<MEDCouplingSkyLineArray> connSla(MEDCouplingSkyLineArray::BuildFromPolyhedronConn(getNodalConnectivity(), getNodalConnectivityIndex()));
const double * coo(_coords->begin());
MCAuto<DataArrayInt> ret(DataArrayInt::New());
// Build BBTree
MCAuto<DataArrayDouble> bboxArr(mDesc->getBoundingBoxForBBTree());
- const double *bbox(bboxArr->begin()),*coords(getCoords()->begin());
- int nCell=getNumberOfCells(), nDescCell=mDesc->getNumberOfCells();
+ const double *bbox(bboxArr->begin()); getCoords()->begin();
+ int nDescCell(mDesc->getNumberOfCells());
BBTree<SPACEDIM,int> myTree(bbox,0,0,nDescCell,-eps);
// Surfaces - handle biggest first
MCAuto<MEDCouplingFieldDouble> surfF = mDesc->getMeasureField(true);
vector<int> candidates, cands2;
myTree.getIntersectingElems(bbox+faceIdx*2*SPACEDIM,candidates);
// Keep only candidates whose normal matches the normal of current face
- for(vector<int>::const_iterator it=candidates.begin();it!=candidates.end();it++)
+ for(vector<int>::const_iterator it2=candidates.begin();it2!=candidates.end();it2++)
{
- bool col = INTERP_KERNEL::isColinear3D(normalsP + faceIdx*SPACEDIM, normalsP + *(it)*SPACEDIM, eps);
- if (*it != faceIdx && col)
- cands2.push_back(*it);
+ bool col = INTERP_KERNEL::isColinear3D(normalsP + faceIdx*SPACEDIM, normalsP + *(it2)*SPACEDIM, eps);
+ if (*it2 != faceIdx && col)
+ cands2.push_back(*it2);
}
if (!cands2.size())
continue;
const int * idsGoodPlaneP(idsGoodPlane->begin());
for (const int * ii = ids->begin(); ii != ids->end(); ii++)
{
- int faceIdx = cands2[idsGoodPlaneP[*ii]];
- hit[faceIdx] = true;
- checkSurf += surfs->begin()[faceIdx];
+ int faceIdx2 = cands2[idsGoodPlaneP[*ii]];
+ hit[faceIdx2] = true;
+ checkSurf += surfs->begin()[faceIdx2];
}
if (fabs(checkSurf - surfs->begin()[faceIdx]) > eps)
{
connSla->findPackIds(polyIndices, sIdxConn, sIdxConnE, packsIds);
// Deletion of old faces
int jj=0;
- for (vector<int>::const_iterator it=polyIndices.begin(); it!=polyIndices.end(); ++it, ++jj)
+ for (vector<int>::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
// 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(*it, packsIds[jj]);
+ connSla->deletePack(*it2, packsIds[jj]);
}
// Insertion of new faces:
for (const int * ii = ids->begin(); ii != ids->end(); ii++)
{
// Build pack from the face to insert:
- int faceIdx = cands2[idsGoodPlane->getIJ(*ii,0)];
+ int faceIdx2 = cands2[idsGoodPlane->getIJ(*ii,0)];
int facePack2Sz;
- const int * facePack2 = connSlaDesc->getSimplePackSafePtr(faceIdx, facePack2Sz); // contains the type!
+ const int * facePack2 = connSlaDesc->getSimplePackSafePtr(faceIdx2, facePack2Sz); // contains the type!
// Insert it in all hit polyhedrons:
- for (vector<int>::const_iterator it=polyIndices.begin(); it!=polyIndices.end(); ++it)
- connSla->pushBackPack(*it, facePack2+1, facePack2+facePack2Sz); // without the type
+ for (vector<int>::const_iterator it2=polyIndices.begin(); it2!=polyIndices.end(); ++it2)
+ connSla->pushBackPack(*it2, facePack2+1, facePack2+facePack2Sz); // without the type
}
}
} // end step1
{
/************************
* STEP 2 -- edges
- /************************/
+ ************************/
// Now we have a face-conform mesh.
// Recompute descending
unsigned start = cDesc2[cIDesc2[eIdx]+1], end = cDesc2[cIDesc2[eIdx]+2];
for (int i3=0; i3 < 3; i3++) // TODO: use fillSonCellNodalConnectivity2 or similar?
vCurr[i3] = coo[start*SPACEDIM+i3] - coo[end*SPACEDIM+i3];
- for(vector<int>::const_iterator it=candidates.begin();it!=candidates.end();it++)
+ for(vector<int>::const_iterator it2=candidates.begin();it2!=candidates.end();it2++)
{
double vOther[3];
- unsigned start2 = cDesc2[cIDesc2[*it]+1], end2 = cDesc2[cIDesc2[*it]+2];
+ unsigned start2 = cDesc2[cIDesc2[*it2]+1], end2 = cDesc2[cIDesc2[*it2]+2];
for (int 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(*it);
+ cands2.push_back(*it2);
}
if (cands2.size() == 1 && cands2[0] == eIdx) // see warning above
continue;