${CMAKE_CURRENT_SOURCE_DIR}/GaussPoints
)
+IF (NOT DEFINED MSVC)
+ ADD_DEFINITIONS(-Wsign-compare -Wconversion)
+ENDIF()
+
SET(PLATFORM_MMAP)
IF(NOT WIN32)
SET(PLATFORM_MMAP "-D_POSIX_MAPPED_FILES")
if(_dim==2)
{
if(_type==NORM_POLYGON)
- return lgth;
+ return FromIdType<unsigned>(lgth);
else
- return lgth/2;
+ return FromIdType<unsigned>(lgth/2);
}
else if(_dim==1)
- return lgth;//NORM_POLYL
+ return FromIdType<unsigned>(lgth);//NORM_POLYL
else
- return std::count(conn,conn+lgth,-1)+1;
+ return (unsigned)std::count(conn,conn+lgth,-1)+1;
}
unsigned CellModel::getNumberOfEdgesIn3D(const mcIdType *conn, mcIdType lgth) const
if(!isDynamic())
return _nb_of_little_sons;
else//polyhedron
- return (lgth-std::count(conn,conn+lgth,-1))/2;
+ return FromIdType<unsigned>(lgth-ToIdType(std::count(conn,conn+lgth,-1)/2));
}
/*!
}
const mcIdType *where2=std::find(where,nodalConn+lgth,-1);
std::copy(where,where2,sonNodalConn);
- return where2-where;
+ return (unsigned)(where2-where);
}
else
throw INTERP_KERNEL::Exception("CellModel::fillSonCellNodalConnectivity2 : no sons on NORM_POLYL !");
where++;
}
const mcIdType *where2=std::find(where,nodalConn+lgth,-1);
- return where2-where;
+ return (unsigned)(where2-where);
}
else
throw INTERP_KERNEL::Exception("CellModel::getNumberOfNodesConstituentTheSon2 : no sons on NORM_POLYL !");
}
else
{
- int p=(lgth+1)/2;
+ mcIdType p=(lgth+1)/2;
std::vector<mcIdType> tmp(2*p);
std::vector<mcIdType>::iterator it=std::copy(conn1,conn1+p,tmp.begin());
std::copy(conn1,conn1+p,it);
char *INTERP_KERNEL::AsmX86::copyToExecMemZone(const std::vector<char>& ml, unsigned& offset) const
{
char *ret=0;
- int lgth=ml.size();
+ std::size_t lgth=ml.size();
#ifdef _POSIX_MAPPED_FILES
# ifdef __APPLE__
ret=(char *)mmap(0,lgth,PROT_EXEC | PROT_WRITE,MAP_ANON | MAP_PRIVATE,-1,0);
for(int k=0;k<nbOfByte;k++)
{
j=i&255;
- v=j;
+ v=(char)j;
ml.push_back(v);
i>>=8;
}
DecompositionInUnitBase &DecompositionInUnitBase::operator*(const DecompositionInUnitBase& other)
{
- _value[0]+=other._value[0]; _value[1]+=other._value[1]; _value[2]+=other._value[2]; _value[3]+=other._value[3]; _value[4]+=other._value[4];
+ // += causes ' conversion to 'short int' from 'int' may alter its value [-Wconversion]'
+ _value[0]=(short)(_value[0]+other._value[0]); _value[1]=(short)(_value[1]+other._value[1]); _value[2]=(short)(_value[2]+other._value[2]); _value[3]=(short)(_value[3]+other._value[3]); _value[4]=(short)(_value[4]+other._value[4]);
_mult_fact_to_base*=other._mult_fact_to_base;
_add_to_base=0.;
return *this;
DecompositionInUnitBase &DecompositionInUnitBase::operator/(const DecompositionInUnitBase& other)
{
- _value[0]-=other._value[0]; _value[1]-=other._value[1]; _value[2]-=other._value[2]; _value[3]-=other._value[3]; _value[4]-=other._value[4];
+ // -= causes ' conversion to 'short int' from 'int' may alter its value [-Wconversion]'
+ _value[0]=(short)(_value[0]-other._value[0]); _value[1]=(short)(_value[1]-other._value[1]); _value[2]=(short)(_value[2]-other._value[2]); _value[3]=(short)(_value[3]-other._value[3]); _value[4]=(short)(_value[4]-other._value[4]);
_mult_fact_to_base/=other._mult_fact_to_base;
_add_to_base=0.;
return *this;
if(!other.isAdimensional())
throw INTERP_KERNEL::Exception("Trying to execute operator ^ with a second member not adimensionnal");
int exp=couldItBeConsideredAsInt(other._mult_fact_to_base);
- _value[0]*=exp; _value[1]*=exp; _value[2]*=exp; _value[3]*=exp; _value[4]*=exp;
+ // *= causes ' conversion to 'short int' from 'int' may alter its value [-Wconversion]'
+ _value[0]=(short)(_value[0]*exp); _value[1]=(short)(_value[1]*exp); _value[2]=(short)(_value[2]*exp); _value[3]=(short)(_value[3]*exp); _value[4]=(short)(_value[4]*exp);
_mult_fact_to_base=powInt(_mult_fact_to_base,exp);
_add_to_base=0.;
return *this;
{
if( _my_nb_gauss )
{
- return _my_gauss_coord.size()/_my_nb_gauss;
+ return (int)_my_gauss_coord.size()/_my_nb_gauss;
}
else
{
{
if( _my_nb_ref )
{
- return _my_reference_coord.size()/_my_nb_ref;
+ return (int)(_my_reference_coord.size()/_my_nb_ref);
}
else
{
aReferenceCoord.push_back(theReferenceCoord[i]);
- GaussInfo* info = new GaussInfo( theGeometry, aGaussCoord, theNbGauss, aReferenceCoord, theNbRef);
+ GaussInfo* info = new GaussInfo( theGeometry, aGaussCoord, FromIdType<int>(theNbGauss), aReferenceCoord, FromIdType<int>(theNbRef));
info->initLocalInfo();
//If info with cell type doesn't exist add it
}
else
{
- int index = std::distance(_my_gauss_info.begin(),it);
+ std::size_t index = std::distance(_my_gauss_info.begin(),it);
delete (*it);
_my_gauss_info[index] = info;
}
std::vector<double> radialDistrib3(radialDistrib.size());
std::transform(radialDistrib2.begin(),radialDistrib2.end(),radialDistrib.begin(),radialDistrib3.begin(),std::minus<double>());
std::vector<double>::iterator iter3=max_element(radialDistrib3.begin(),radialDistrib3.end());
- int i=iter3-radialDistrib3.begin();
+ std::size_t i=iter3-radialDistrib3.begin();
// ok for e1 - Let's go.
EdgeInfLin *e1=new EdgeInfLin(nodeToTest,radialDistrib[i]+radialDistrib3[i]/2.);
double ref=e1->getCharactValue(*nodeToTest);
*/
void Edge::Interpolate1DLin(const std::vector<double>& distrib1, const std::vector<double>& distrib2, std::map<int, std::map<int,double> >& result)
{
- int nbOfV1=distrib1.size()-1;
- int nbOfV2=distrib2.size()-1;
+ std::size_t nbOfV1=distrib1.size()-1;
+ std::size_t nbOfV2=distrib2.size()-1;
Node *n1=new Node(0.,0.); Node *n3=new Node(0.,0.);
Node *n2=new Node(0.,0.); Node *n4=new Node(0.,0.);
MergePoints commonNode;
- for(int i=0;i<nbOfV1;i++)
+ for(unsigned int i=0;i<nbOfV1;i++)
{
std::vector<double>::const_iterator iter=find_if(distrib2.begin()+1,distrib2.end(),bind2nd(std::greater_equal<double>(),distrib1[i]));
if(iter!=distrib2.end())
{
- for(int j=(iter-1)-distrib2.begin();j<nbOfV2;j++)
+ for(unsigned int j=(unsigned)((iter-1)-distrib2.begin());j<nbOfV2;j++)
{
if(distrib2[j]<=distrib1[i+1])
{
tmpp2[tmpp.size()+1]=endId;
std::vector<mcIdType>::iterator itt=std::unique(tmpp2.begin(),tmpp2.end());
tmpp2.resize(std::distance(tmpp2.begin(),itt));
- int nbOfEdges=tmpp2.size()-1;
- for(int i=0;i<nbOfEdges;i++)
+ std::size_t nbOfEdges=tmpp2.size()-1;
+ for(std::size_t i=0;i<nbOfEdges;i++)
{
edgesThis.push_back(tmpp2[i]);
edgesThis.push_back(tmpp2[i+1]);
std::vector<mcIdType>& edgesOther, std::vector<double>& addCoo, std::map<INTERP_KERNEL::Node *,mcIdType>& mapAddCoo) const
{
if (!_direction)
- skipStartOrEnd *= -1; // invert value - see QuadraticPolygon::splitAbs()
+ skipStartOrEnd = (short)(-skipStartOrEnd); // invert value - see QuadraticPolygon::splitAbs()
_ptr->fillGlobalInfoAbs2(mapThis,mapOther,offset1,offset2,fact,baryX,baryY,skipStartOrEnd,edgesOther,addCoo,mapAddCoo);
}
//
std::map<INTERP_KERNEL::Node *,mcIdType>::const_iterator thisStart(mapThis.find(curThis->getStartNode())),thisEnd(mapThis.find(curThis->getEndNode())),
otherStart(mapOther.find(curOtherTmp->getStartNode())),otherEnd(mapOther.find(curOtherTmp->getEndNode()));
- int thisStart2(thisStart==mapThis.end()?-1:(*thisStart).second), thisEnd2(thisEnd==mapThis.end()?-1:(*thisEnd).second),
+ mcIdType thisStart2(thisStart==mapThis.end()?-1:(*thisStart).second), thisEnd2(thisEnd==mapThis.end()?-1:(*thisEnd).second),
otherStart2(otherStart==mapOther.end()?-1:(*otherStart).second+offset1),otherEnd2(otherEnd==mapOther.end()?-1:(*otherEnd).second+offset1);
//
if(curThis->getPtr()->intersectWith(curOtherTmp->getPtr(),merge,*cThis,*cOther))
// Converting back to integer connectivity:
if(otherTmp._sub_edges.size()>1) // only if a new point has been added (i.e. an actual intersection was done)
{
- int jj = 0, sz(otherTmp._sub_edges.size());
+ std::size_t jj = 0, sz(otherTmp._sub_edges.size());
for(std::list<ElementaryEdge *>::const_iterator it=otherTmp._sub_edges.begin();it!=otherTmp._sub_edges.end();it++, jj++)
{
short skipStartOrEnd = jj == 0 ? -1 : (jj == sz-1 ? 1 : 0); // -1 means START, 1 means END, 0 other
if(!isQuad)
{
bool direct=descBg[edgePos]>0;
- mcIdType edgeId=abs(descBg[edgePos])-1; // back to C indexing mode
+ mcIdType edgeId=std::abs(descBg[edgePos])-1; // back to C indexing mode
const std::vector<mcIdType>& subEdge=intersectEdges[edgeId];
std::size_t nbOfSubEdges=subEdge.size()/2;
for(std::size_t j=0;j<nbOfSubEdges;j++)
delete e1; delete e2;
//
bool direct=descBg[edgePos]>0;
- mcIdType edgeId=abs(descBg[edgePos])-1;
+ mcIdType edgeId=std::abs(descBg[edgePos])-1;
const std::vector<mcIdType>& subEdge=intersectEdges[edgeId];
std::size_t nbOfSubEdges=subEdge.size()/2;
if(colinearity)
for(std::size_t i=0;i<nbOfSeg;i++)//loop over all edges of pol2
{
bool direct=descBg[i]>0;
- mcIdType edgeId=abs(descBg[i])-1;//current edge id of pol2
+ mcIdType edgeId=std::abs(descBg[i])-1;//current edge id of pol2
std::map<mcIdType,std::vector<INTERP_KERNEL::ElementaryEdge *> >::const_iterator it1=alreadyExistingIn2.find(descBg[i]),it2=alreadyExistingIn2.find(-descBg[i]);
if(it1!=alreadyExistingIn2.end() || it2!=alreadyExistingIn2.end())
{
std::size_t nbOfEdgesIn1=std::distance(descBg1,descEnd1);
for(std::size_t j=0;j<nbOfEdgesIn1;j++)
{
- mcIdType edgeId1=abs(descBg1[j])-1;
+ mcIdType edgeId1=std::abs(descBg1[j])-1;
if(std::find(c.begin(),c.end(),edgeId1)!=c.end())
{
idIns1.push_back(std::pair<mcIdType,std::pair<bool,mcIdType> >(edgeId1,std::pair<bool,mcIdType>(descBg1[j]>0,offset1)));// it exists an edge into pol1 given by tuple (idIn1,direct1) that is colinear at edge 'edgeId' in pol2
//std::pair<edgeId1); direct1=descBg1[j]>0;
}
- offset1+=intersectEdges1[edgeId1].size()/2;//offset1 is used to find the INTERP_KERNEL::Edge * instance into pol1 that will be part of edge into pol2
+ offset1+=ToIdType(intersectEdges1[edgeId1].size()/2);//offset1 is used to find the INTERP_KERNEL::Edge * instance into pol1 that will be part of edge into pol2
}
directos=idIns1.empty();
}
bool direction11,found=false;
bool direct1;//store if needed the direction in 1
mcIdType offset2;
- std::size_t nbOfSubEdges1;
+ mcIdType nbOfSubEdges1;
for(std::vector<std::pair<mcIdType,std::pair<bool,mcIdType> > >::const_iterator it=idIns1.begin();it!=idIns1.end() && !found;it++)
{
mcIdType idIn1=(*it).first;//store if needed the cell id in 1
direct1=(*it).second.first;
offset1=(*it).second.second;
const std::vector<mcIdType>& subEdge1PossiblyAlreadyIn1=intersectEdges1[idIn1];
- nbOfSubEdges1=subEdge1PossiblyAlreadyIn1.size()/2;
+ nbOfSubEdges1=ToIdType(subEdge1PossiblyAlreadyIn1.size()/2);
offset2=0;
- for(std::size_t k=0;k<nbOfSubEdges1 && !found;k++)
+ for(mcIdType k=0;k<nbOfSubEdges1 && !found;k++)
{//perform a loop on all subedges of pol1 that includes edge 'edgeId' of pol2. For the moment we iterate only on subedges of ['idIn1']... To improve
if(subEdge1PossiblyAlreadyIn1[2*k]==idBg && subEdge1PossiblyAlreadyIn1[2*k+1]==idEnd)
{ direction11=true; found=true; }
}
else
{//the current subedge of edge 'edgeId' of pol2 is part of the colinear edge 'idIn1' of pol1 -> reuse Edge instance of pol1
- ElementaryEdge *e=pol1[offset1+(direct1?offset2:nbOfSubEdges1-offset2-1)];
+ ElementaryEdge *e=pol1[FromIdType<int>(offset1+(direct1?offset2:nbOfSubEdges1-offset2-1))];
Edge *ee=e->getPtr();
ee->incrRef();
ElementaryEdge *e2=new ElementaryEdge(ee,!(direct1^direction11));
for(std::size_t i=0;i<nbOfSeg;i++)//loop over all edges of pol2
{
bool direct=descBg[i]>0;
- mcIdType edgeId=abs(descBg[i])-1;//current edge id of pol2
+ mcIdType edgeId=std::abs(descBg[i])-1;//current edge id of pol2
const std::vector<mcIdType>& c=colinear1[edgeId];
if(c.empty())
continue;
mcIdType offset1=0;
for(std::size_t j=0;j<nbOfEdgesIn1;j++)
{
- mcIdType edgeId1=abs(descBg1[j])-1;
+ mcIdType edgeId1=std::abs(descBg1[j])-1;
if(std::find(c.begin(),c.end(),edgeId1)!=c.end())
{
for(std::size_t k=0;k<nbOfSubEdges;k++)
mcIdType idIn1=edgeId1;
bool direct1=descBg1[j]>0;
const std::vector<mcIdType>& subEdge1PossiblyAlreadyIn1=intersectEdges1[idIn1];
- std::size_t nbOfSubEdges1=subEdge1PossiblyAlreadyIn1.size()/2;
+ mcIdType nbOfSubEdges1=ToIdType(subEdge1PossiblyAlreadyIn1.size()/2);
mcIdType offset2=0;
bool found=false;
- for(std::size_t kk=0;kk<nbOfSubEdges1 && !found;kk++)
+ for(mcIdType kk=0;kk<nbOfSubEdges1 && !found;kk++)
{
found=(subEdge1PossiblyAlreadyIn1[2*kk]==idBg && subEdge1PossiblyAlreadyIn1[2*kk+1]==idEnd) || (subEdge1PossiblyAlreadyIn1[2*kk]==idEnd && subEdge1PossiblyAlreadyIn1[2*kk+1]==idBg);
if(!found)
}
if(found)
{
- ElementaryEdge *e=pol1[offset1+(direct1?offset2:nbOfSubEdges1-offset2-1)];
+ ElementaryEdge *e=pol1[(int)(offset1+(direct1?offset2:nbOfSubEdges1-offset2-1))];
e->getPtr()->declareOn();
}
}
}
- offset1+=intersectEdges1[edgeId1].size()/2;//offset1 is used to find the INTERP_KERNEL::Edge * instance into pol1 that will be part of edge into pol2
+ offset1+=ToIdType(intersectEdges1[edgeId1].size()/2);//offset1 is used to find the INTERP_KERNEL::Edge * instance into pol1 that will be part of edge into pol2
}
}
}
}
else
{
- int quadOff = lgth/2;
+ mcIdType quadOff = lgth/2;
mcIdType *tmpQuad = new mcIdType[quadOff];
for(int i = 0; i < quadOff; i++)
if(conn[i] != conn[(i+1)%quadOff] || conn[i] != conn[i+quadOff]) // zip nul segments/arcs (quad point must match too)
{
std::set<mcIdType> nodes(conn,conn+lgth);
nodes.erase(-1);
- int nbOfNodes=(int)nodes.size();
- int magicNumber=100*nbOfNodes+nbOfFaces;
+ std::size_t nbOfNodes=nodes.size();
+ std::size_t magicNumber=100*nbOfNodes+nbOfFaces;
switch(magicNumber)
{
case 806:
std::vector< std::pair<mcIdType,mcIdType> >::iterator it=std::find(oppEdges.begin(),oppEdges.end(),pInOpp);
if(it==oppEdges.end())//the opposite edge of side face is not found opposite face ... maybe problem of orientation of polyhedron
return false;
- int pos2=(int)std::distance(oppEdges.begin(),it);
- int offset=pos-pos2;
+ mcIdType pos2=ToIdType(std::distance(oppEdges.begin(),it));
+ mcIdType offset=pos-pos2;
if(offset<0)
offset+=lgthBaseFace;
//this is the end copy the result
std::set<mcIdType> quad4S(quad4,quad4+4);
w=conn;
bool ok=true;
- int point=-1;
+ mcIdType point=-1;
for(std::size_t i=0;i<5 && ok;i++)
{
if(i!=quad4_pos)
if(std::find_if(conn+lgth,conn+lgth+nbOfFaces,std::bind2nd(std::not_equal_to<mcIdType>(),ToIdType(INTERP_KERNEL::NORM_TRI3)))==conn+lgth+nbOfFaces)
{
std::set<mcIdType> tribase(conn,conn+3);
- int point=-1;
+ mcIdType point=-1;
bool ok=true;
for(int i=1;i<4 && ok;i++)
{
return std::string(meth);
}
-bool INTERP_KERNEL::InterpolationOptions::setInterpolationOptions(long print_level,
+bool INTERP_KERNEL::InterpolationOptions::setInterpolationOptions(int print_level,
std::string intersection_type,
double precision,
double median_plane,
double bounding_box_adjustment,
double bounding_box_adjustment_abs,
double max_distance_for_3Dsurf_intersect,
- long orientation,
+ int orientation,
bool measure_abs,
std::string splitting_policy)
{
void init();
- bool setInterpolationOptions(long print_level,
+ bool setInterpolationOptions(int print_level,
std::string intersection_type,
double precision,
double median_plane,
double bounding_box_adjustment,
double bounding_box_adjustment_abs,
double max_distance_for_3Dsurf_intersect,
- long orientation,
+ int orientation,
bool measure_abs,
std::string splitting_policy);
void copyOptions(const InterpolationOptions & other) { *this = other; }
case NORM_POLYHED:
{
mcIdType nbOfFaces(ToIdType(std::count(nodalConnBg,nodalConnEnd,-1)+1));
- std::size_t nbOfTetra(std::distance(nodalConnBg,nodalConnEnd)-nbOfFaces+1);
+ mcIdType nbOfTetra(ToIdType(std::distance(nodalConnBg,nodalConnEnd)-nbOfFaces+1));
addCoords.resize((nbOfFaces+1)*3);
tetrasNodalConn.resize(nbOfTetra*4);
mcIdType *conn(&tetrasNodalConn[0]);
const mcIdType *work(nodalConnBg);
double *tmp(&addCoords[0]),*tmp2(&addCoords[3*nbOfFaces]);
tmp2[0]=0.; tmp2[1]=0.; tmp2[2]=0.;
- for(mcIdType i=0;i<nbOfFaces;i++,tmp+=3)
+ for(int i=0;i<nbOfFaces;i++,tmp+=3)
{
tmp[0]=0.; tmp[1]=0.; tmp[2]=0.;
- mcIdType nbOfNodesOfFace(ToIdType(std::distance(work,std::find(work,nodalConnEnd,-1))));
- for(mcIdType j=0;j<nbOfNodesOfFace;j++,conn+=4)
+ std::size_t nbOfNodesOfFace(std::distance(work,std::find(work,nodalConnEnd,-1)));
+ for(std::size_t j=0;j<nbOfNodesOfFace;j++,conn+=4)
{
- conn[0]=work[j]; conn[1]=work[(j+1)%nbOfNodesOfFace]; conn[2]=-(i+1); conn[3]=-(nbOfFaces+1);
+ conn[0]=work[j]; conn[1]=work[(j+1)%nbOfNodesOfFace]; conn[2]=-(i+1); conn[3]=ToIdType(-(nbOfFaces+1));
tmp[0]+=coords[3*work[j]+0]; tmp[1]+=coords[3*work[j]+1]; tmp[2]+=coords[3*work[j]+2];
}
- tmp[0]/=nbOfNodesOfFace; tmp[1]/=nbOfNodesOfFace; tmp[2]/=nbOfNodesOfFace;
+ double nbNF = (double)nbOfNodesOfFace;
+ tmp[0]/=nbNF; tmp[1]/=nbNF; tmp[2]/=nbNF;
tmp2[0]+=tmp[0]; tmp2[1]+=tmp[1]; tmp2[2]+=tmp[2];
work+=nbOfNodesOfFace+1;
}
- tmp2[0]/=nbOfFaces; tmp2[1]/=nbOfFaces; tmp2[2]/=nbOfFaces;
+ double nbF = (double)nbOfFaces;
+ tmp2[0]/=nbF; tmp2[1]/=nbF; tmp2[2]/=nbF;
return ;
}
default:
const long double delta = MULT_PREC_F * ( std::fabs(term1) + std::fabs(term2) );
- if( epsilonEqual(_doubleProducts[8*seg + dp], 0.0, THRESHOLD_F * delta))
+ if( epsilonEqual(_doubleProducts[8*seg + dp], 0.0, (double)(THRESHOLD_F * delta)))
{
// debug output
#if LOG_LEVEL >= 5
const long double delta = MULT_PREC_F * (std::fabs(p_term) + std::fabs(q_term) + std::fabs(r_term));
#endif
- if( epsilonEqual( p_term + q_term + r_term, 0.0, THRESHOLD_F * delta) )
+ if( epsilonEqual( p_term + q_term + r_term, 0.0, (double)(THRESHOLD_F * delta)) )
{
LOG(4, "Reset imprecise triple product for corner " << corner << " to zero" );
return 0.0;
* \throw If the spatial discretization of \a this field is NULL.
* \throw If no Gauss localization object found for the given cell.
*/
-mcIdType MEDCouplingField::getGaussLocalizationIdOfOneCell(int cellId) const
+mcIdType MEDCouplingField::getGaussLocalizationIdOfOneCell(mcIdType cellId) const
{
if(!((const MEDCouplingFieldDiscretization *)_type))
throw INTERP_KERNEL::Exception("Spatial discretization not set ! Impossible to call getGaussLocalizationIdOfOneCell method !");
MEDCOUPLING_EXPORT mcIdType getGaussLocalizationIdOfOneType(INTERP_KERNEL::NormalizedCellType type) const;
MEDCOUPLING_EXPORT std::set<mcIdType> getGaussLocalizationIdsOfOneType(INTERP_KERNEL::NormalizedCellType type) const;
MEDCOUPLING_EXPORT mcIdType getNbOfGaussLocalization() const;
- MEDCOUPLING_EXPORT mcIdType getGaussLocalizationIdOfOneCell(int cellId) const;
+ MEDCOUPLING_EXPORT mcIdType getGaussLocalizationIdOfOneCell(mcIdType cellId) const;
MEDCOUPLING_EXPORT void getCellIdsHavingGaussLocalization(int locId, std::vector<mcIdType>& cellIds) const;
MEDCOUPLING_EXPORT const MEDCouplingGaussLocalization& getGaussLocalization(int locId) const;
MEDCOUPLING_EXPORT void updateTime() const;
* \ref py_mcfielddouble_getValueOnPos "Here is a Python example".
* \endif
*/
-void MEDCouplingFieldDouble::getValueOnPos(int i, int j, int k, double *res) const
+void MEDCouplingFieldDouble::getValueOnPos(mcIdType i, mcIdType j, mcIdType k, double *res) const
{
const DataArrayDouble *arr=timeDiscr()->getArray();
if(!_mesh)
* \ref py_mcfielddouble_getValueOnMulti "Here is a Python example".
* \endif
*/
-DataArrayDouble *MEDCouplingFieldDouble::getValueOnMulti(const double *spaceLoc, int nbOfPoints) const
+DataArrayDouble *MEDCouplingFieldDouble::getValueOnMulti(const double *spaceLoc, mcIdType nbOfPoints) const
{
const DataArrayDouble *arr=timeDiscr()->getArray();
if(!_mesh)
MEDCOUPLING_EXPORT void normMax(double *res) const;
MEDCOUPLING_EXPORT double integral(int compId, bool isWAbs) const;
MEDCOUPLING_EXPORT void integral(bool isWAbs, double *res) const;
- MEDCOUPLING_EXPORT void getValueOnPos(int i, int j, int k, double *res) const;
+ MEDCOUPLING_EXPORT void getValueOnPos(mcIdType i, mcIdType j, mcIdType k, double *res) const;
MEDCOUPLING_EXPORT void getValueOn(const double *spaceLoc, double *res) const;
MEDCOUPLING_EXPORT void getValueOn(const double *spaceLoc, double time, double *res) const;
- MEDCOUPLING_EXPORT DataArrayDouble *getValueOnMulti(const double *spaceLoc, int nbOfPoints) const;
+ MEDCOUPLING_EXPORT DataArrayDouble *getValueOnMulti(const double *spaceLoc, mcIdType nbOfPoints) const;
MEDCOUPLING_EXPORT void applyLin(double a, double b, int compoId);
MEDCOUPLING_EXPORT void applyLin(double a, double b);
MEDCOUPLING_EXPORT MEDCouplingFieldDouble &operator=(double value);
{
public:
MEDCOUPLING_EXPORT MCAuto<DataArrayDouble> convertToDblArr() const;
- MEDCOUPLING_EXPORT MCAuto<DataArrayIdType> convertToIntArr() const;
+ MEDCOUPLING_EXPORT MCAuto<DataArrayInt> convertToIntArr() const;
MEDCOUPLING_EXPORT MCAuto<DataArrayFloat> convertToFloatArr() const;
MEDCOUPLING_EXPORT void applyLin(T a, T b, std::size_t compoId);
MEDCOUPLING_EXPORT void applyLin(T a, T b);
MEDCOUPLING_EXPORT bool isEqualWithoutConsideringStr(const DataArrayChar& other) const;
MEDCOUPLING_EXPORT std::string repr() const;
MEDCOUPLING_EXPORT std::string reprZip() const;
- MEDCOUPLING_EXPORT DataArrayIdType *convertToIntArr() const;
+ MEDCOUPLING_EXPORT DataArrayInt *convertToIntArr() const;
MEDCOUPLING_EXPORT DataArrayChar *selectByTupleId(const mcIdType *new2OldBg, const mcIdType *new2OldEnd) const { return this->mySelectByTupleId(new2OldBg,new2OldEnd); }
MEDCOUPLING_EXPORT DataArrayChar *selectByTupleId(const DataArrayIdType& di) const { return this->mySelectByTupleId(di); }
MEDCOUPLING_EXPORT DataArrayChar *selectByTupleIdSafe(const mcIdType *new2OldBg, const mcIdType *new2OldEnd) const { return DataArrayTemplate<char>::mySelectByTupleIdSafe(new2OldBg,new2OldEnd); }
* \return DataArrayInt * - the new instance of DataArrayInt.
*/
template<class T>
- MCAuto<DataArrayIdType> DataArrayTemplateClassic<T>::convertToIntArr() const
+ MCAuto<DataArrayInt> DataArrayTemplateClassic<T>::convertToIntArr() const
{
- return convertToOtherTypeOfArr<mcIdType>();
+ return convertToOtherTypeOfArr<int>();
}
/*!
* array to the new one.
* \return DataArrayIdType * - the new instance of DataArrayChar.
*/
-DataArrayIdType *DataArrayChar::convertToIntArr() const
+DataArrayInt *DataArrayChar::convertToIntArr() const
{
checkAllocated();
- DataArrayIdType *ret=DataArrayIdType::New();
+ DataArrayInt *ret=DataArrayInt::New();
ret->alloc(getNumberOfTuples(),getNumberOfComponents());
std::size_t nbOfVals=getNbOfElems();
const char *src=getConstPointer();
- mcIdType *dest=ret->getPointer();
+ int *dest=ret->getPointer();
std::copy(src,src+nbOfVals,dest);
ret->copyStringInfoFrom(*this);
return ret;
class DataArrayInt64Tuple;
class DataArrayFloatTuple;
class DataArrayDoubleTuple;
+ class DataArrayByteTuple;
class DataArrayInt32Iterator;
class DataArrayInt64Iterator;
+ class DataArrayByteIterator;
template<>
struct MEDCOUPLING_EXPORT Traits<double>
static const char ArrayTypeName[];
typedef DataArrayByte ArrayTypeCh;
typedef DataArrayChar ArrayType;
+ typedef DataArrayByteTuple ArrayTuple;
+ typedef DataArrayByteIterator IteratorType;
};
}
}
types->transformWithIndArr(MEDCOUPLING2VTKTYPETRADUCER,MEDCOUPLING2VTKTYPETRADUCER+INTERP_KERNEL::NORM_MAXTYPE+1);
types->writeVTK(ofs,8,"UInt8","types",byteData);
- offsets->writeVTK(ofs,8,"Int32","offsets",byteData);
+ std::string vtkTypeName = Traits<mcIdType>::VTKReprStr;
+ offsets->writeVTK(ofs,8,vtkTypeName,"offsets",byteData);
if(szFaceOffsets!=0)
{//presence of Polyhedra
connectivity->reAlloc(szConn);
- faceoffsets->writeVTK(ofs,8,"Int32","faceoffsets",byteData);
+ faceoffsets->writeVTK(ofs,8,vtkTypeName,"faceoffsets",byteData);
MCAuto<DataArrayIdType> faces=DataArrayIdType::New(); faces->alloc(szFaceOffsets,1);
w1=faces->getPointer();
for(mcIdType i=0;i<nbOfCells;i++)
w6=w5+1;
}
}
- faces->writeVTK(ofs,8,"Int32","faces",byteData);
+ faces->writeVTK(ofs,8,vtkTypeName,"faces",byteData);
}
- connectivity->writeVTK(ofs,8,"Int32","connectivity",byteData);
+ connectivity->writeVTK(ofs,8,vtkTypeName,"connectivity",byteData);
ofs << " </Cells>\n";
ofs << " </Piece>\n";
ofs << " </" << getVTKDataSetType() << ">\n";
arr->setInfoOnComponent(1,"hhhh");
arr->setInfoOnComponent(2,"jj");
arr->setInfoOnComponent(3,"kkkkkk");
- MCAuto<DataArrayIdType> arr2(arr->convertToIntArr());
+ MCAuto<DataArrayInt> arr2(arr->convertToIntArr());
MCAuto<DataArrayDouble> arr3(arr2->convertToDblArr());
CPPUNIT_ASSERT(arr->isEqual(*arr3,1e-14));
arr->decrRef();
#include "MEDCouplingMappedExtrudedMesh.hxx"
#include "MEDCouplingFieldDouble.hxx"
#include "MEDCouplingMemArray.hxx"
+#include "MEDCouplingMemArray.txx"
#include "MEDCouplingGaussLocalization.hxx"
#include <cmath>
const double expected1[30]={2.,3.,2.,3.,1.,1., 12.,13.,12.,13.,11.,11., 22.,23.,22.,23.,21.,21., 32.,33.,32.,33.,31.,31., 42.,43.,42.,43.,41.,41.};
for(int i=0;i<30;i++)
CPPUNIT_ASSERT_DOUBLES_EQUAL(expected1[i],a2->getIJ(0,i),1e-14);
- MCAuto<DataArrayIdType> a3(a1->convertToIntArr());
- DataArrayIdType *a4=static_cast<DataArrayIdType *>(a3->keepSelectedComponents(arr2V));
+ MCAuto<DataArrayInt> a3(a1->convertToIntArr());
+ DataArrayInt *a4=static_cast<DataArrayInt *>(a3->keepSelectedComponents(arr2V));
CPPUNIT_ASSERT_EQUAL(6,(int)a4->getNumberOfComponents());
CPPUNIT_ASSERT_EQUAL(5,(int)a4->getNumberOfTuples());
CPPUNIT_ASSERT(std::string(a4->getInfoOnComponent(0))=="bbbb");
CPPUNIT_ASSERT(std::string(a4->getInfoOnComponent(4))=="aaaa");
CPPUNIT_ASSERT(std::string(a4->getInfoOnComponent(5))=="aaaa");
for(int i=0;i<30;i++)
- CPPUNIT_ASSERT_EQUAL(ToIdType(expected1[i]),a4->getIJ(0,i));
+ CPPUNIT_ASSERT_EQUAL((int)expected1[i],a4->getIJ(0,i));
// setSelectedComponents
const mcIdType arr3[2]={3,2};
std::vector<std::size_t> arr3V(arr3,arr3+2);
const double expected2[30]={2.,4.,3.,3.,1.,1., 12.,14.,13.,13.,11.,11., 22.,24.,23.,23.,21.,21., 32.,34.,33.,33.,31.,31., 42.,44.,43.,43.,41.,41.};
for(int i=0;i<30;i++)
CPPUNIT_ASSERT_DOUBLES_EQUAL(expected2[i],a2->getIJ(0,i),1e-14);
- MCAuto<DataArrayIdType> a6=a5->convertToIntArr();
+ MCAuto<DataArrayInt> a6=a5->convertToIntArr();
a6->setInfoOnComponent(0,"eeee");
a6->setInfoOnComponent(1,"ffff");
a4->setSelectedComponents(a6,arr4V);
for(int i=0;i<35;i++)
CPPUNIT_ASSERT_DOUBLES_EQUAL(expected1[i],da1->getIJ(0,i),1e-10);
//
- MCAuto<DataArrayIdType> dai1=da1C->convertToIntArr();
- MCAuto<DataArrayIdType> dai3=da3->convertToIntArr();
+ MCAuto<DataArrayInt> dai1=da1C->convertToIntArr();
+ MCAuto<DataArrayInt> dai3=da3->convertToIntArr();
dai1->meldWith(dai3);
CPPUNIT_ASSERT_EQUAL(5,(int)dai1->getNumberOfComponents());
CPPUNIT_ASSERT_EQUAL(7,(int)dai1->getNumberOfTuples());
CPPUNIT_ASSERT(dai1->getInfoOnComponent(3)=="c1da3");
CPPUNIT_ASSERT(dai1->getInfoOnComponent(4)=="c2da3");
for(int i=0;i<35;i++)
- CPPUNIT_ASSERT_EQUAL(ToIdType(expected1[i]),dai1->getIJ(0,i));
+ CPPUNIT_ASSERT_EQUAL((int)expected1[i],dai1->getIJ(0,i));
// test of static method DataArrayDouble::meld
DataArrayDouble *da4=DataArrayDouble::Meld(da1C,da3);
CPPUNIT_ASSERT_EQUAL(5,(int)da4->getNumberOfComponents());
CPPUNIT_ASSERT_DOUBLES_EQUAL(expected1[i],da4->getIJ(0,i),1e-10);
// test of static method DataArrayIdType::meld
dai1=da1C->convertToIntArr();
- DataArrayIdType *dai4=DataArrayIdType::Meld(dai1,dai3);
+ DataArrayInt *dai4=DataArrayInt::Meld(dai1,dai3);
CPPUNIT_ASSERT_EQUAL(5,(int)dai4->getNumberOfComponents());
CPPUNIT_ASSERT_EQUAL(7,(int)dai4->getNumberOfTuples());
CPPUNIT_ASSERT(dai4->getInfoOnComponent(0)=="c0da1");
d1->deepCopyFrom(*d);
CPPUNIT_ASSERT(d->isEqual(*d1,1e-12));
//
- MCAuto<DataArrayIdType> d2=d->convertToIntArr();
- DataArrayIdType *d4=DataArrayIdType::New();
+ MCAuto<DataArrayInt> d2=d->convertToIntArr();
+ DataArrayInt *d4=DataArrayInt::New();
CPPUNIT_ASSERT(!d2->isEqual(*d4));
d4->deepCopyFrom(*d2);
CPPUNIT_ASSERT(d2->isEqual(*d4));
#include "MEDCouplingMappedExtrudedMesh.hxx"
#include "MEDCouplingFieldDouble.hxx"
#include "MEDCouplingMemArray.hxx"
+#include "MEDCouplingMemArray.txx"
#include "MEDCouplingGaussLocalization.hxx"
#include "MEDCouplingMultiFields.hxx"
#include "MEDCouplingFieldOverTime.hxx"
const double expected1[12]={2.,3.,5.,6.,7.,8.,9.,10.,11.,12.,13.,15.};
d1->alloc(6,2);
std::copy(val1,val1+12,d1->getPointer());
- MCAuto<DataArrayIdType> d2=d1->convertToIntArr();
+ MCAuto<DataArrayInt> d2=d1->convertToIntArr();
//
d1->abs();
for(int i=0;i<12;i++)
const mcIdType expected2[12]={2,3,5,6,7,8,9,10,11,12,13,15};
d2->abs();
for(int i=0;i<12;i++)
- CPPUNIT_ASSERT_EQUAL(expected2[i],d2->getIJ(0,i));
+ CPPUNIT_ASSERT_EQUAL((int)expected2[i],d2->getIJ(0,i));
//
d1->decrRef();
}
}
//! [CppSnippet_MEDCouplingUMesh_checkDeepEquivalWith_1]
//! [CppSnippet_MEDCouplingUMesh_checkDeepEquivalWith_2]
- mcIdType cellCompPol = 1; // "permuted same orientation" - policy of medium severity
+ int cellCompPol = 1; // "permuted same orientation" - policy of medium severity
DataArrayIdType *nOld2New, *cOld2New;
mesh1->checkDeepEquivalWith( mesh2, cellCompPol, 0.002, cOld2New, nOld2New );
const mcIdType nOld2NewExpected[4] = { 3, 0, 1, 2 };
ADD_DEFINITIONS(${PYTHON_DEFINITIONS} ${NUMPY_DEFINITIONS} ${SCIPY_DEFINITIONS})
+IF (NOT DEFINED MSVC)
+ ADD_DEFINITIONS(-Wsign-compare -Wconversion)
+ENDIF()
+
SET_SOURCE_FILES_PROPERTIES(MEDCoupling.i PROPERTIES CPLUSPLUS ON)
IF ("${PYTHON_VERSION_MAJOR}" STREQUAL "3")
SET_SOURCE_FILES_PROPERTIES(MEDCoupling.i PROPERTIES SWIG_FLAGS "-py3")
std::string repr() const;
std::string reprZip() const;
std::string reprNotTooLong() const;
- ARRAY *invertArrayO2N2N2O(INT newNbOfElem) const;
- ARRAY *invertArrayN2O2O2N(INT oldNbOfElem) const;
- ARRAY *invertArrayO2N2N2OBis(INT newNbOfElem) const;
+ ARRAY *invertArrayO2N2N2O(mcIdType newNbOfElem) const;
+ ARRAY *invertArrayN2O2O2N(mcIdType oldNbOfElem) const;
+ ARRAY *invertArrayO2N2N2OBis(mcIdType newNbOfElem) const;
DataArrayIdType *indicesOfSubPart(const ARRAY& partOfThis) const;
ARRAY *fromNoInterlace() const;
ARRAY *toNoInterlace() const;
- ARRAY *selectByTupleIdSafeSlice(INT bg, INT end, INT step) const;
+ ARRAY *selectByTupleIdSafeSlice(mcIdType bg, mcIdType end, mcIdType step) const;
DataArrayIdType *checkAndPreparePermutation() const;
DataArrayIdType *buildPermArrPerLevel() const;
- bool isIota(INT sizeExpected) const;
+ bool isIota(mcIdType sizeExpected) const;
bool isUniform(INT val) const;
INT checkUniformAndGuess() const;
bool hasUniqueValues() const;
- ARRAY *subArray(INT tupleIdBg, INT tupleIdEnd=-1) const;
+ ARRAY *subArray(mcIdType tupleIdBg, mcIdType tupleIdEnd=-1) const;
void transpose();
ARRAY *changeNbOfComponents(std::size_t newNbOfComp, INT dftValue) const;
void meldWith(const ARRAY *other);
- void setPartOfValues1(const ARRAY *a, INT bgTuples, INT endTuples, INT stepTuples, INT bgComp, INT endComp, INT stepComp, bool strictCompoCompare=true);
- void setPartOfValuesSimple1(INT a, INT bgTuples, INT endTuples, INT stepTuples, INT bgComp, INT endComp, INT stepComp);
+ void setPartOfValues1(const ARRAY *a, mcIdType bgTuples, mcIdType endTuples, mcIdType stepTuples, mcIdType bgComp, mcIdType endComp, mcIdType stepComp, bool strictCompoCompare=true);
+ void setPartOfValuesSimple1(INT a, mcIdType bgTuples, mcIdType endTuples, mcIdType stepTuples, mcIdType bgComp, mcIdType endComp, mcIdType stepComp);
void setPartOfValuesAdv(const ARRAY *a, const DataArrayIdType *tuplesSelec);
- void getTuple(INT tupleId, INT *res) const;
+ void getTuple(mcIdType tupleId, INT *res) const;
INT getIJ(std::size_t tupleId, std::size_t compoId) const;
- INT getIJSafe(INT tupleId, INT compoId) const;
+ INT getIJSafe(std::size_t tupleId, std::size_t compoId) const;
INT front() const;
INT back() const;
- void setIJ(INT tupleId, INT compoId, INT newVal);
- void setIJSilent(INT tupleId, INT compoId, INT newVal);
+ void setIJ(mcIdType tupleId, mcIdType compoId, INT newVal);
+ void setIJSilent(mcIdType tupleId, mcIdType compoId, INT newVal);
INT *getPointer();
const INT *getConstPointer() const;
ARRAY ## Iterator *iterator();
DataArrayIdType *findRangeIdForEachTuple(const ARRAY *ranges) const;
ARRAY *findIdInRangeForEachTuple(const ARRAY *ranges) const;
void sortEachPairToMakeALinkedList();
- ARRAY *duplicateEachTupleNTimes(INT nbTimes) const;
+ ARRAY *duplicateEachTupleNTimes(mcIdType nbTimes) const;
ARRAY *getDifferentValues() const;
static ARRAY *Add(const ARRAY *a1, const ARRAY *a2);
void addEqual(const ARRAY *other);
{
if(PyInt_Check(nbOfTuples))
{
- mcIdType nbOfTuples1=PyInt_AS_LONG(nbOfTuples);
+ mcIdType nbOfTuples1=ToIdType(PyInt_AS_LONG(nbOfTuples));
if(nbOfTuples1<0)
throw INTERP_KERNEL::Exception("ARRAY::New : should be a positive set of allocated memory !");
if(nbOfComp)
{
if(PyInt_Check(nbOfComp))
{//ARRAY.New([1,3,4,5],2,2)
- mcIdType nbOfCompo=PyInt_AS_LONG(nbOfComp);
+ mcIdType nbOfCompo=ToIdType(PyInt_AS_LONG(nbOfComp));
if(nbOfCompo<0)
throw INTERP_KERNEL::Exception("ARRAY::New : should be a positive number of components !");
MCAuto<ARRAY> ret=ARRAY::New();
}
else if(PyInt_Check(elt0))
{
- INT nbOfTuples1=PyInt_AS_LONG(elt0);
+ INT nbOfTuples1=(INT)PyInt_AS_LONG(elt0);
if(nbOfTuples1<0)
throw INTERP_KERNEL::Exception("ARRAY::New : should be a positive set of allocated memory !");
if(nbOfTuples)
{
if(PyInt_Check(nbOfTuples))
{//ARRAY.New(5,2)
- INT nbOfCompo=PyInt_AS_LONG(nbOfTuples);
+ INT nbOfCompo=(INT)PyInt_AS_LONG(nbOfTuples);
if(nbOfCompo<0)
throw INTERP_KERNEL::Exception("ARRAY::New : should be a positive number of components !");
MCAuto<ARRAY> ret=ARRAY::New();
}
else if(MEDCouplingHasNumPyBindings() && PyArray_Check(elt0) && nbOfTuples==NULL && nbOfComp==NULL)
{//ARRAY.New(numpyArray)
- return BuildNewInstance<ARRAY,INT>(elt0,NPY_INT32,&PyCallBackDataArrayInt_RefType,"INT32");
+ return BuildNewInstance<ARRAY,INT>(elt0,NPYTraits<INT>::NPYObjectType,NPYTraits<INT>::NPYFunc,MEDCoupling::Traits<INT>::NPYStr);
}
else
throw INTERP_KERNEL::Exception(msg.c_str());
return self->reprNotTooLong();
}
- INT __len__() const
+ mcIdType __len__() const
{
if(self->isAllocated())
{
PyObject *accumulate() const
{
- mcIdType sz=self->getNumberOfComponents();
+ mcIdType sz=ToIdType(self->getNumberOfComponents());
INTERP_KERNEL::AutoPtr<INT> tmp=new INT[sz];
self->accumulate((INT *)tmp);
return convertIntArrToPyList((const INT *)tmp,sz);
GetIndicesOfSliceExplicitely(slic,&strt,&stp,&step,"ARRAY::buildExplicitArrOfSliceOnScaledArr (wrap) : the input slice is invalid !");
if(strt==std::numeric_limits<INT>::max() || stp==std::numeric_limits<INT>::max())
throw INTERP_KERNEL::Exception("ARRAY::buildExplicitArrOfSliceOnScaledArr (wrap) : the input slice contains some unknowns that can't be determined in static method ! Call DataArray::getSlice (non static) instead !");
- return self->buildExplicitArrOfSliceOnScaledArr(strt,stp,step);
+ return self->buildExplicitArrOfSliceOnScaledArr((INT)strt,(INT)stp,(INT)step);
}
PyObject *getMinMaxValues() const
{
if(PyInt_Check(nbOfTuples))
{
- mcIdType nbOfTuples1=PyInt_AS_LONG(nbOfTuples);
+ mcIdType nbOfTuples1=ToIdType(PyInt_AS_LONG(nbOfTuples));
if(nbOfTuples1<0)
throw INTERP_KERNEL::Exception("ARRAY::setValue : should be a positive set of allocated memory !");
if(nbOfComp && nbOfComp != Py_None)
{
if(PyInt_Check(nbOfComp))
{//ARRAY.setValues([1,3,4,5],2,2)
- mcIdType nbOfCompo=PyInt_AS_LONG(nbOfComp);
+ mcIdType nbOfCompo=ToIdType(PyInt_AS_LONG(nbOfComp));
if(nbOfCompo<0)
throw INTERP_KERNEL::Exception("ARRAY::setValue : should be a positive number of components !");
std::vector<INT> tmp=fillArrayWithPyListInt2<INT>(li,nbOfTuples1,nbOfCompo);
PyObject *getValuesAsTuple() const
{
const INT *vals=self->getConstPointer();
- mcIdType nbOfComp=self->getNumberOfComponents();
+ mcIdType nbOfComp=ToIdType(self->getNumberOfComponents());
mcIdType nbOfTuples=self->getNumberOfTuples();
return convertIntArrToPyListOfTuple(vals,nbOfComp,nbOfTuples);
}
DataArrayIdType *ret0=MEDCoupling::ARRAY::MakePartition(groups,newNb,fidsOfGroups);
PyObject *ret = PyList_New(2);
PyList_SetItem(ret,0,SWIG_NewPointerObj(SWIG_as_voidptr(ret0),SWIGTITraits<mcIdType>::TI, SWIG_POINTER_OWN | 0 ));
- mcIdType sz=fidsOfGroups.size();
+ std::size_t sz=fidsOfGroups.size();
PyObject *ret1 = PyList_New(sz);
- for(mcIdType i=0;i<sz;i++)
+ for(std::size_t i=0;i<sz;i++)
PyList_SetItem(ret1,i,convertIntArrToPyList2(fidsOfGroups[i]));
PyList_SetItem(ret,1,ret1);
return ret;
PyObject *getTuple(mcIdType tupleId)
{
- mcIdType sz=self->getNumberOfComponents();
+ mcIdType sz=ToIdType(self->getNumberOfComponents());
INTERP_KERNEL::AutoPtr<INT> tmp=new INT[sz];
self->getTuple(tupleId,tmp);
return convertIntArrToPyList((const INT*)tmp,sz);
mcIdType index(PyObject *obj) const
{
- mcIdType nbOfCompo=self->getNumberOfComponents();
+ std::size_t nbOfCompo=self->getNumberOfComponents();
switch(nbOfCompo)
{
case 1:
bool __contains__(PyObject *obj) const
{
- mcIdType nbOfCompo=self->getNumberOfComponents();
+ std::size_t nbOfCompo=self->getNumberOfComponents();
switch(nbOfCompo)
{
case 0:
const char msg2[]="ARRAY::__getitem__ : Mismatch of slice values in 2nd parameter (components) !";
self->checkAllocated();
mcIdType nbOfTuples=self->getNumberOfTuples();
- mcIdType nbOfComponents=self->getNumberOfComponents();
+ std::size_t nbOfComponents=self->getNumberOfComponents();
mcIdType it1;
std::size_t ic1;
std::vector<mcIdType> vt1;
std::pair<mcIdType, std::pair<mcIdType,mcIdType> > pt1,pc1;
DataArrayIdType *dt1=0,*dc1=0;
mcIdType sw;
- convertObjToPossibleCpp3(obj,nbOfTuples,nbOfComponents,sw,it1,ic1,vt1,vc1,pt1,pc1,dt1,dc1);
+ convertObjToPossibleCpp3(obj,nbOfTuples,(int)nbOfComponents,sw,it1,ic1,vt1,vc1,pt1,pc1,dt1,dc1);
MCAuto<ARRAY> ret;
switch(sw)
{
self->checkAllocated();
const char msg[]="Unexpected situation in __setitem__ !";
mcIdType nbOfTuples=self->getNumberOfTuples();
- mcIdType nbOfComponents=self->getNumberOfComponents();
+ int nbOfComponents=(int)self->getNumberOfComponents();
mcIdType sw1,sw2;
INT i1;
std::vector<INT> v1;
{
const char msg2[]="ARRAY ## Tuple::__getitem__ : Mismatch of slice values in 2nd parameter (components) !";
mcIdType sw;
- mcIdType singleVal;
- std::vector<mcIdType> multiVal;
+ INT singleVal;
+ std::vector<INT> multiVal;
std::pair<mcIdType, std::pair<mcIdType,mcIdType> > slic;
MEDCoupling::DataArrayIdType *daIntTyypp=0;
const INT *pt=self->getConstPointer();
- INT nbc=self->getNumberOfCompo();
- convertIntStarOrSliceLikePyObjToCppWithNegIntInterp(obj,nbc,sw,singleVal,multiVal,slic,daIntTyypp);
+ INT nbc=(INT)self->getNumberOfCompo();
+ convertIntStarOrSliceLikePyObjToCppWithNegIntInterp(obj,ToIdType(nbc),sw,singleVal,multiVal,slic,daIntTyypp);
switch(sw)
{
case 1:
{
- if(singleVal>=nbc)
+ if(singleVal>=(INT)nbc)
{
std::ostringstream oss;
oss << "Requesting for id " << singleVal << " having only " << nbc << " components !";
case 2:
{
PyObject *t=PyTuple_New(multiVal.size());
- for(INT j=0;j<(INT)multiVal.size();j++)
+ for(std::size_t j=0;j<multiVal.size();j++)
{
INT cid=multiVal[j];
- if(cid>=nbc)
+ if(cid>=(INT)nbc)
{
std::ostringstream oss;
oss << "Requesting for id #" << cid << " having only " << nbc << " components !";
}
case 3:
{
- INT sz=DataArray::GetNumberOfItemGivenBES(slic.first,slic.second.first,slic.second.second,msg2);
+ mcIdType sz=DataArray::GetNumberOfItemGivenBES(slic.first,slic.second.first,slic.second.second,msg2);
PyObject *t=PyTuple_New(sz);
for(INT j=0;j<sz;j++)
PyTuple_SetItem(t,j,PyInt_FromLong(pt[slic.first+j*slic.second.second]));
std::vector<mcIdType> multiValV;
std::pair<mcIdType, std::pair<mcIdType,mcIdType> > slicV;
MEDCoupling::ARRAY ## Tuple *daIntTyyppV=0;
- INT nbc=self->getNumberOfCompo();
+ mcIdType nbc=ToIdType(self->getNumberOfCompo());
convertObjToPossibleCpp22<INT>(value,nbc,sw1,singleValV,multiValV,slicV,daIntTyyppV);
INT singleVal;
std::vector<INT> multiVal;
{
case 1:
{
- pt[singleVal]=singleValV;
+ pt[singleVal]=(INT)singleValV;
return self;
}
case 2:
oss << "Requesting for setting id # " << singleVal << " with a list or tuple with size != 1 ! ";
throw INTERP_KERNEL::Exception(oss.str().c_str());
}
- pt[singleVal]=multiValV[0];
+ pt[singleVal]=(INT)multiValV[0];
return self;
}
case 4:
oss << "Requesting for setting id # " << *it << " having only " << nbc << " components !";
throw INTERP_KERNEL::Exception(oss.str().c_str());
}
- pt[*it]=singleValV;
+ pt[*it]=(INT)singleValV;
}
return self;
}
oss << "Requesting for setting id # " << pos << " having only " << nbc << " components !";
throw INTERP_KERNEL::Exception(oss.str().c_str());
}
- pt[multiVal[i]]=multiValV[i];
+ pt[multiVal[i]]=(INT)multiValV[i];
}
return self;
}
}
case 3:
{
- INT sz=DataArray::GetNumberOfItemGivenBES(slic.first,slic.second.first,slic.second.second,msg2);
+ std::size_t sz=DataArray::GetNumberOfItemGivenBES(slic.first,slic.second.first,slic.second.second,msg2);
switch(sw1)
{
case 1:
{
- for(INT j=0;j<sz;j++)
- pt[slic.first+j*slic.second.second]=singleValV;
+ for(std::size_t j=0;j<sz;j++)
+ pt[slic.first+j*slic.second.second]=(INT)singleValV;
return self;
}
case 2:
{
- if(sz!=(INT)multiValV.size())
+ if(sz!=multiValV.size())
{
std::ostringstream oss;
oss << "Mismatch length of during assignment : " << multiValV.size() << " != " << sz << " !";
throw INTERP_KERNEL::Exception(oss.str().c_str());
}
- for(INT j=0;j<sz;j++)
- pt[slic.first+j*slic.second.second]=multiValV[j];
+ for(std::size_t j=0;j<sz;j++)
+ pt[slic.first+j*slic.second.second]=(INT)multiValV[j];
return self;
}
case 4:
{
const INT *ptV=daIntTyyppV->getConstPointer();
- if(sz>(INT)daIntTyyppV->getNumberOfCompo())
+ if(sz>daIntTyyppV->getNumberOfCompo())
{
std::ostringstream oss;
oss << "Mismatch length of during assignment : " << nbc << " != " << daIntTyyppV->getNumberOfCompo() << " !";
throw INTERP_KERNEL::Exception(oss.str().c_str());
}
- for(INT j=0;j<sz;j++)
+ for(std::size_t j=0;j<sz;j++)
pt[slic.first+j*slic.second.second]=ptV[j];
return self;
}
pass
# test of static method DataArrayInt::meld
dai1=da1C.convertToIntArr();
- dai4=DataArrayInt.Meld(dai1,dai3);
- tmp=DataArrayInt.Meld([dai1,dai3]);
+ dai4=DataArrayInt32.Meld(dai1,dai3);
+ tmp=DataArrayInt32.Meld([dai1,dai3]);
self.assertTrue(dai4.isEqual(tmp))
self.assertEqual(5,dai4.getNumberOfComponents());
self.assertEqual(7,dai4.getNumberOfTuples());
self.assertTrue(d.isEqual(d1,1e-12));
#
d2=d.convertToIntArr();
- d4=DataArrayInt.New();
+ d4=DataArrayInt32.New();
self.assertTrue(not d2.isEqual(d4));
d4.deepCopyFrom(d2);
self.assertTrue(d2.isEqual(d4));
@unittest.skipUnless(checkFreeMemory((223456789*16)/(1024)), "Not enough memory")
def testSwig2BigMem(self):
- if MEDCouplingSizeOfVoidStar()==64:
+ if MEDCouplingSizeOfVoidStar()==64 and MEDCouplingSizeOfIDs()==32:
d=DataArrayAsciiChar(223456789,16)
self.assertTrue(d.getNumberOfTuples(),223456789)
self.assertTrue(d.getNumberOfComponents(),16)
m=MEDCoupling1SGTUMesh("m",NORM_QUAD4)
mem_m=m.getHeapMemorySize()
m.allocateCells(5)
- self.assertIn(m.getHeapMemorySize() - mem_m, list(range(5 * 4 * 4, 5 * 4 * 4 + 32)))
+ self.assertIn(m.getHeapMemorySize() - mem_m, list(range(5 * 4 * MEDCouplingSizeOfIDs()//8, 5 * 4 * MEDCouplingSizeOfIDs()//8 + 32)))
self.assertEqual(m.getNodalConnectivity().getNbOfElemAllocated(),20)
m.setCoords(um.getCoords())
m.insertNextCell([1,0,6,7])
self.assertEqual(d.getInfoOnComponents(),["aa","bbb"])
ref=d.getHeapMemorySize()
d.desallocate()
- self.assertEqual(ref-d.getHeapMemorySize(),6*4)
+ self.assertEqual(ref-d.getHeapMemorySize(),6*MEDCouplingSizeOfIDs()//8)
self.assertTrue(not d.isAllocated())
self.assertEqual(d.getInfoOnComponents(),["aa","bbb"])
self.assertRaises(InterpKernelException,d.checkAllocated)
m.setCoords(arrX,arrX)
f=MEDCouplingFieldInt(ON_CELLS)
f.setMesh(m)
- arr=DataArrayInt(8) ; arr.iota() ;f.setArray(arr)
+ arr=DataArrayInt32(8) ; arr.iota() ;f.setArray(arr)
self.assertRaises(InterpKernelException,f.checkConsistencyLight)
- arr=DataArrayInt(9) ; arr.iota() ;f.setArray(arr)
+ arr=DataArrayInt32(9) ; arr.iota() ;f.setArray(arr)
f.checkConsistencyLight()
f.setTimeUnit("ms")
self.assertEqual(f.getTimeUnit(),"ms")
m1=MEDCouplingCMesh() ; m1.setCoords(DataArrayDouble([0,1,2,3]),DataArrayDouble([0,1,2,3,4]))
m1=m1.buildUnstructured() ; m1.setName("mesh")
f1=MEDCouplingFieldInt(ON_CELLS) ; f1.setMesh(m1)
- arr1=DataArrayInt([(0,1),(2,3),(4,5),(6,7),(8,9),(10,11),(12,13),(14,15),(16,17),(18,19),(20,21),(22,23)]) ; arr1.setInfoOnComponents(["aa","bbb"])
+ arr1=DataArrayInt32([(0,1),(2,3),(4,5),(6,7),(8,9),(10,11),(12,13),(14,15),(16,17),(18,19),(20,21),(22,23)]) ; arr1.setInfoOnComponents(["aa","bbb"])
f1.setArray(arr1) ; f1.setName("f1") ; f1.setTime(2.,3,4)
#
m2=MEDCouplingCMesh() ; m2.setCoords(DataArrayDouble([0,1,2,3]),DataArrayDouble([0,1,2,3,4]))
m2=m2.buildUnstructured() ; m2.setName("mesh")
f2=MEDCouplingFieldInt(ON_CELLS) ; f2.setMesh(m2)
- arr2=DataArrayInt([(0,1),(2,3),(4,5),(6,7),(8,9),(10,11),(12,13),(14,15),(16,17),(18,19),(20,21),(22,23)]) ; arr2.setInfoOnComponents(["aa","bbb"])
+ arr2=DataArrayInt32([(0,1),(2,3),(4,5),(6,7),(8,9),(10,11),(12,13),(14,15),(16,17),(18,19),(20,21),(22,23)]) ; arr2.setInfoOnComponents(["aa","bbb"])
f2.setArray(arr2) ; f2.setName("f1") ; f2.setTime(2.,3,4)
#
self.assertTrue(f1.isEqual(f2,1e-12,0))
#
for fd,expected in ((ON_NODES,False),(ON_CELLS,True)):
f4=MEDCouplingFieldInt(fd) ; f4.setMesh(m2) ; f4.setTime(2.,3,4)
- arr4=DataArrayInt([(0,1),(2,3),(4,5),(6,7),(8,9),(10,11),(12,13),(14,15),(16,17),(18,19),(20,21),(22,23)]) ; arr4.setInfoOnComponents(["aa","bbb"])
+ arr4=DataArrayInt32([(0,1),(2,3),(4,5),(6,7),(8,9),(10,11),(12,13),(14,15),(16,17),(18,19),(20,21),(22,23)]) ; arr4.setInfoOnComponents(["aa","bbb"])
f4.setArray(arr4) ; f4.setName("f1")
self.assertEqual(f1.isEqual(f4,1e-12,0),expected)
pass
"""Test focused of new wrapped methods for MEDCouplingFieldInt thanks to code factorization."""
d=DataArrayDouble(7) ; d.iota()
m=MEDCouplingUMesh.Build1DMeshFromCoords(d)
- f=MEDCouplingFieldInt(ON_CELLS) ; f.setMesh(m) ; arr=DataArrayInt(6) ; arr.iota() ; f.setArray(arr) ; f.checkConsistencyLight()
+ f=MEDCouplingFieldInt(ON_CELLS) ; f.setMesh(m) ; arr=DataArrayInt32(6) ; arr.iota() ; f.setArray(arr) ; f.checkConsistencyLight()
f_0=f[::2] # test is here
- self.assertTrue(f_0.getArray().isEqual(DataArrayInt([0,2,4])))
+ self.assertTrue(f_0.getArray().isEqual(DataArrayInt32([0,2,4])))
self.assertTrue(f_0.getMesh().isEqual(m[[0,2,4]],1e-12))
#
- f2=MEDCouplingFieldInt(ON_NODES) ; f2.setMesh(m) ; arr=DataArrayInt(7) ; arr.iota() ; f2.setArray(arr) ; f2.checkConsistencyLight()
+ f2=MEDCouplingFieldInt(ON_NODES) ; f2.setMesh(m) ; arr=DataArrayInt32(7) ; arr.iota() ; f2.setArray(arr) ; f2.checkConsistencyLight()
f_1=f2[::2] # test is here
- self.assertTrue(f_1.getArray().isEqual(DataArrayInt([0,1,2,3,4,5])))
+ self.assertTrue(f_1.getArray().isEqual(DataArrayInt32([0,1,2,3,4,5])))
m_1=m[[0,2,4]] ; m_1.zipCoords()
self.assertTrue(f_1.getMesh().isEqual(m_1,1e-12))
pass
%}
-%template(ivec) std::vector<int>;
-%template(lvec) std::vector<long>;
%template(dvec) std::vector<double>;
%template(svec) std::vector<std::string>;
//typedef std::int32_t mcIdType;
typedef int mcIdType;
typedef DataArrayInt32 DataArrayIdType;
+%template(ivec) std::vector<int>;
+%template(i64vec) std::vector<long>;
#else
//typedef std::int64_t mcIdType;
typedef long int mcIdType;
typedef DataArrayInt64 DataArrayIdType;
+%template(ivec) std::vector<long>;
+%template(i32vec) std::vector<int>;
#endif
Py_ssize_t sz(sizeof(MEDCouplingUMesh::MEDCOUPLING2VTKTYPETRADUCER)/sizeof(decltype(MEDCouplingUMesh::MEDCOUPLING2VTKTYPETRADUCER[0])));
auto maxElt(*std::max_element(MEDCouplingUMesh::MEDCOUPLING2VTKTYPETRADUCER,MEDCouplingUMesh::MEDCOUPLING2VTKTYPETRADUCER+sz));
auto szOut(maxElt+1);
- std::vector< int > retCpp(szOut,-1);
+ std::vector< mcIdType > retCpp(szOut,-1);
mcIdType id(0);
for(const mcIdType *it=MEDCouplingUMesh::MEDCOUPLING2VTKTYPETRADUCER;it!=MEDCouplingUMesh::MEDCOUPLING2VTKTYPETRADUCER+sz;it++,id++)
{
return ret2;
}
- int getCellContainingPoint(PyObject *p, double eps) const
+ mcIdType getCellContainingPoint(PyObject *p, double eps) const
{
double val;
DataArrayDouble *a;
for(std::size_t j=0;j<vals.size()/3;j++)
{
PyObject *ret1=PyList_New(3);
- PyList_SetItem(ret1,0,SWIG_From_int(vals[3*j]));
- PyList_SetItem(ret1,1,SWIG_From_int(vals[3*j+1]));
- PyList_SetItem(ret1,2,SWIG_From_int(vals[3*j+2]));
+ PyList_SetItem(ret1,0,PyInt_FromLong(vals[3*j]));
+ PyList_SetItem(ret1,1,PyInt_FromLong(vals[3*j+1]));
+ PyList_SetItem(ret1,2,PyInt_FromLong(vals[3*j+2]));
PyList_SetItem(ret,j,ret1);
}
return ret;
for(std::size_t j=0;j<code.size()/3;j++)
{
PyObject *ret00=PyList_New(3);
- PyList_SetItem(ret00,0,SWIG_From_int(code[3*j]));
- PyList_SetItem(ret00,1,SWIG_From_int(code[3*j+1]));
- PyList_SetItem(ret00,2,SWIG_From_int(code[3*j+2]));
+ PyList_SetItem(ret00,0,PyInt_FromLong(code[3*j]));
+ PyList_SetItem(ret00,1,PyInt_FromLong(code[3*j+1]));
+ PyList_SetItem(ret00,2,PyInt_FromLong(code[3*j+2]));
PyList_SetItem(ret0,j,ret00);
}
PyTuple_SetItem(ret,0,ret0);
PyObject *ret(PyTuple_New(3));
PyTuple_SetItem(ret,0,convertDblArrToPyList2(a0));
PyTuple_SetItem(ret,1,convertIntArrToPyList2(a1));
- mcIdType sz(a2.size());
+ std::size_t sz(a2.size());
PyObject *ret2(PyList_New(sz));
{
- for(mcIdType i=0;i<sz;i++)
+ for(std::size_t i=0;i<sz;i++)
PyList_SetItem(ret2,i,PyString_FromString(a2[i].c_str()));
}
PyTuple_SetItem(ret,2,ret2);
static const char MSG[]="MEDCouplingMesh.__setstate__ : expected input is a tuple of size 2 !";
if(!PyTuple_Check(inp))
throw INTERP_KERNEL::Exception(MSG);
- mcIdType sz(PyTuple_Size(inp));
+ std::size_t sz(PyTuple_Size(inp));
if(sz!=2)
throw INTERP_KERNEL::Exception(MSG);
PyObject *elt0(PyTuple_GetItem(inp,0));
DataArrayIdType *ret0=self->buildNewNumberingFromCommonNodesFormat(comm,commIndex,newNbOfNodes);
PyObject *res = PyList_New(2);
PyList_SetItem(res,0,SWIG_NewPointerObj(SWIG_as_voidptr(ret0),SWIGTITraits<mcIdType>::TI, SWIG_POINTER_OWN | 0 ));
- PyList_SetItem(res,1,SWIG_From_int(newNbOfNodes));
+ PyList_SetItem(res,1,PyInt_FromLong(newNbOfNodes));
return res;
}
PyObject *res = PyList_New(3);
PyList_SetItem(res,0,SWIG_NewPointerObj(SWIG_as_voidptr(ret0),SWIGTITraits<mcIdType>::TI, SWIG_POINTER_OWN | 0 ));
PyList_SetItem(res,1,SWIG_From_bool(ret1));
- PyList_SetItem(res,2,SWIG_From_int(ret2));
+ PyList_SetItem(res,2,PyInt_FromLong(ret2));
return res;
}
PyObject *res = PyList_New(3);
PyList_SetItem(res,0,SWIG_NewPointerObj(SWIG_as_voidptr(ret0),SWIGTITraits<mcIdType>::TI, SWIG_POINTER_OWN | 0 ));
PyList_SetItem(res,1,SWIG_From_bool(ret1));
- PyList_SetItem(res,2,SWIG_From_int(ret2));
+ PyList_SetItem(res,2,PyInt_FromLong(ret2));
return res;
}
static PyObject *FuseUMeshesOnSameCoords(PyObject *ms, int compType)
{
- mcIdType sz;
+ std::size_t sz;
std::vector<const MEDCouplingUMesh *> meshes;
convertFromPyObjVectorOfObj<const MEDCoupling::MEDCouplingUMesh *>(ms,SWIGTYPE_p_MEDCoupling__MEDCouplingUMesh,"MEDCouplingUMesh",meshes);
std::vector<DataArrayIdType *> corr;
MEDCouplingUMesh *um=MEDCouplingUMesh::FuseUMeshesOnSameCoords(meshes,compType,corr);
sz=corr.size();
PyObject *ret1=PyList_New(sz);
- for(int i=0;i<sz;i++)
+ for(std::size_t i=0;i<sz;i++)
PyList_SetItem(ret1,i,SWIG_NewPointerObj(SWIG_as_voidptr(corr[i]),SWIGTITraits<mcIdType>::TI, SWIG_POINTER_OWN | 0 ));
PyObject *ret=PyList_New(2);
PyList_SetItem(ret,0,SWIG_NewPointerObj(SWIG_as_voidptr(um),SWIGTYPE_p_MEDCoupling__MEDCouplingUMesh, SWIG_POINTER_OWN | 0 ));
{
return MEDCouplingIMesh::New();
}
- static MEDCouplingIMesh *New(const std::string& meshName, mcIdType spaceDim, PyObject *nodeStrct, PyObject *origin, PyObject *dxyz)
+ static MEDCouplingIMesh *New(const std::string& meshName, int spaceDim, PyObject *nodeStrct, PyObject *origin, PyObject *dxyz)
{
static const char msg0[]="MEDCouplingIMesh::New : error on 'origin' parameter !";
static const char msg1[]="MEDCouplingIMesh::New : error on 'dxyz' parameter !";
return MEDCouplingIMesh::New(meshName,spaceDim,nodeStrctPtr,nodeStrctPtr+sz,originPtr,originPtr+sz1,dxyzPtr,dxyzPtr+sz2);
}
- MEDCouplingIMesh(const std::string& meshName, mcIdType spaceDim, PyObject *nodeStrct, PyObject *origin, PyObject *dxyz)
+ MEDCouplingIMesh(const std::string& meshName, int spaceDim, PyObject *nodeStrct, PyObject *origin, PyObject *dxyz)
{
return MEDCoupling_MEDCouplingIMesh_New__SWIG_1(meshName,spaceDim,nodeStrct,origin,dxyz);
}
void setGaussLocalizationOnType(INTERP_KERNEL::NormalizedCellType type, const std::vector<double>& refCoo,
const std::vector<double>& gsCoo, const std::vector<double>& wg);
void clearGaussLocalizations();
- MEDCouplingGaussLocalization& getGaussLocalization(mcIdType locId);
+ MEDCouplingGaussLocalization& getGaussLocalization(int locId);
mcIdType getNbOfGaussLocalization() const;
mcIdType getGaussLocalizationIdOfOneCell(mcIdType cellId) const;
- const MEDCouplingGaussLocalization& getGaussLocalization(mcIdType locId) const;
+ const MEDCouplingGaussLocalization& getGaussLocalization(int locId) const;
mcIdType getGaussLocalizationIdOfOneType(INTERP_KERNEL::NormalizedCellType type) const;
void setDiscretization(MEDCouplingFieldDiscretization *newDisc);
%extend {
}
}
- PyObject *getCellIdsHavingGaussLocalization(mcIdType locId) const
+ PyObject *getCellIdsHavingGaussLocalization(int locId) const
{
std::vector<mcIdType> tmp;
self->getCellIdsHavingGaussLocalization(locId,tmp);
for(std::vector<DataArrayDouble *>::iterator it=arrs.begin();it!=arrs.end();it++)
if(*it)
(*it)->incrRef();
- int sz=arrs.size();
+ std::size_t sz=arrs.size();
PyObject *ret=PyTuple_New(sz);
- for(int i=0;i<sz;i++)
+ for(std::size_t i=0;i<sz;i++)
{
if(arrs[i])
PyTuple_SetItem(ret,i,SWIG_NewPointerObj(SWIG_as_voidptr(arrs[i]),SWIGTYPE_p_MEDCoupling__DataArrayDouble, SWIG_POINTER_OWN | 0 ));
const char msg[]="Python wrap of MEDCouplingFieldDouble::getValueOn : ";
const double *spaceLoc=convertObjToPossibleCpp5_Safe(sl,sw,val,a,aa,bb,msg,1,spaceDim,true);
//
- int sz=self->getNumberOfComponents();
+ mcIdType sz=ToIdType(self->getNumberOfComponents());
INTERP_KERNEL::AutoPtr<double> res=new double[sz];
self->getValueOn(spaceLoc,res);
return convertDblArrToPyList<double>(res,sz);
PyObject *getValueOnPos(mcIdType i, mcIdType j, mcIdType k) const
{
- int sz=self->getNumberOfComponents();
+ mcIdType sz=ToIdType(self->getNumberOfComponents());
INTERP_KERNEL::AutoPtr<double> res=new double[sz];
self->getValueOnPos(i,j,k,res);
return convertDblArrToPyList<double>(res,sz);
double v0; MEDCoupling::DataArrayDouble *v1(0); MEDCoupling::DataArrayDoubleTuple *v2(0); std::vector<double> v3;
const double *inp=convertObjToPossibleCpp5_Safe2(locs,sw,v0,v1,v2,v3,"wrap of MEDCouplingFieldDouble::getValueOnMulti",
mesh->getSpaceDimension(),true,nbPts);
- return self->getValueOnMulti(inp,nbPts);
+ return self->getValueOnMulti(inp,(int)nbPts);
}
PyObject *getValueOn(PyObject *sl, double time) const
const double *spaceLoc=convertObjToPossibleCpp5_Safe(sl,sw,val,a,aa,bb,msg,1,spaceDim,true);
//
//
- int sz=self->getNumberOfComponents();
+ mcIdType sz=ToIdType(self->getNumberOfComponents());
INTERP_KERNEL::AutoPtr<double> res=new double[sz];
self->getValueOn(spaceLoc,time,res);
return convertDblArrToPyList<double>(res,sz);
}
PyObject *accumulate() const
{
- int sz=self->getNumberOfComponents();
+ mcIdType sz=ToIdType(self->getNumberOfComponents());
INTERP_KERNEL::AutoPtr<double> tmp=new double[sz];
self->accumulate(tmp);
return convertDblArrToPyList<double>(tmp,sz);
}
PyObject *integral(bool isWAbs) const
{
- int sz=self->getNumberOfComponents();
+ mcIdType sz=ToIdType(self->getNumberOfComponents());
INTERP_KERNEL::AutoPtr<double> tmp=new double[sz];
self->integral(isWAbs,tmp);
return convertDblArrToPyList<double>(tmp,sz);
}
PyObject *getWeightedAverageValue(bool isWAbs=true) const
{
- int sz=self->getNumberOfComponents();
+ mcIdType sz=ToIdType(self->getNumberOfComponents());
INTERP_KERNEL::AutoPtr<double> tmp=new double[sz];
self->getWeightedAverageValue(tmp,isWAbs);
return convertDblArrToPyList<double>(tmp,sz);
}
PyObject *normL1() const
{
- int sz=self->getNumberOfComponents();
+ mcIdType sz=ToIdType(self->getNumberOfComponents());
INTERP_KERNEL::AutoPtr<double> tmp=new double[sz];
self->normL1(tmp);
return convertDblArrToPyList<double>(tmp,sz);
}
PyObject *normL2() const
{
- int sz=self->getNumberOfComponents();
+ mcIdType sz=ToIdType(self->getNumberOfComponents());
INTERP_KERNEL::AutoPtr<double> tmp=new double[sz];
self->normL2(tmp);
return convertDblArrToPyList<double>(tmp,sz);
}
PyObject *normMax() const
{
- int sz=self->getNumberOfComponents();
+ mcIdType sz=ToIdType(self->getNumberOfComponents());
INTERP_KERNEL::AutoPtr<double> tmp=new double[sz];
self->normMax(tmp);
return convertDblArrToPyList<double>(tmp,sz);
DataArrayDoubleTuple *aa,*aa2;
std::vector<double> bb,bb2;
mcIdType sw;
- mcIdType spaceDim=3;
+ int spaceDim=3;
const char msg[]="Python wrap of MEDCouplingFieldDouble::extractSlice3D : 1st parameter for origin.";
const char msg2[]="Python wrap of MEDCouplingFieldDouble::extractSlice3D : 2nd parameter for vector.";
const double *orig=convertObjToPossibleCpp5_Safe(origin,sw,val,a,aa,bb,msg,1,spaceDim,true);
{
std::vector<const MEDCoupling::MEDCouplingFieldDouble *> tmp;
convertFromPyObjVectorOfObj<const MEDCoupling::MEDCouplingFieldDouble *>(li,SWIGTYPE_p_MEDCoupling__MEDCouplingFieldDouble,"MEDCouplingFieldDouble",tmp);
- int sz=tmp.size();
+ std::size_t sz=tmp.size();
std::vector<MEDCouplingFieldDouble *> fs(sz);
- for(int i=0;i<sz;i++)
+ for(std::size_t i=0;i<sz;i++)
fs[i]=const_cast<MEDCouplingFieldDouble *>(tmp[i]);
return MEDCouplingMultiFields::New(fs);
}
{
std::vector<const MEDCoupling::MEDCouplingFieldDouble *> tmp;
convertFromPyObjVectorOfObj<const MEDCoupling::MEDCouplingFieldDouble *>(li,SWIGTYPE_p_MEDCoupling__MEDCouplingFieldDouble,"MEDCouplingFieldDouble",tmp);
- int sz=tmp.size();
+ std::size_t sz=tmp.size();
std::vector<MEDCouplingFieldDouble *> fs(sz);
- for(int i=0;i<sz;i++)
+ for(std::size_t i=0;i<sz;i++)
fs[i]=const_cast<MEDCouplingFieldDouble *>(tmp[i]);
return MEDCouplingMultiFields::New(fs);
}
PyObject *getFields() const
{
std::vector<const MEDCouplingFieldDouble *> fields=self->getFields();
- int sz=fields.size();
+ std::size_t sz=fields.size();
PyObject *res = PyList_New(sz);
- for(int i=0;i<sz;i++)
+ for(std::size_t i=0;i<sz;i++)
{
if(fields[i])
{
PyObject *getMeshes() const
{
std::vector<MEDCouplingMesh *> ms=self->getMeshes();
- int sz=ms.size();
+ std::size_t sz=ms.size();
PyObject *res = PyList_New(sz);
- for(int i=0;i<sz;i++)
+ for(std::size_t i=0;i<sz;i++)
{
if(ms[i])
{
{
std::vector<int> refs;
std::vector<MEDCouplingMesh *> ms=self->getDifferentMeshes(refs);
- int sz=ms.size();
+ std::size_t sz=ms.size();
PyObject *res = PyList_New(sz);
- for(int i=0;i<sz;i++)
+ for(std::size_t i=0;i<sz;i++)
{
if(ms[i])
{
PyObject *getArrays() const
{
std::vector<DataArrayDouble *> ms=self->getArrays();
- int sz=ms.size();
+ std::size_t sz=ms.size();
PyObject *res = PyList_New(sz);
- for(int i=0;i<sz;i++)
+ for(std::size_t i=0;i<sz;i++)
{
if(ms[i])
{
{
std::vector< std::vector<int> > refs;
std::vector<DataArrayDouble *> ms=self->getDifferentArrays(refs);
- int sz=ms.size();
+ std::size_t sz=ms.size();
PyObject *res = PyList_New(sz);
PyObject *res2 = PyList_New(sz);
- for(int i=0;i<sz;i++)
+ for(std::size_t i=0;i<sz;i++)
{
if(ms[i])
{
{
std::vector<const MEDCoupling::MEDCouplingFieldDouble *> tmp;
convertFromPyObjVectorOfObj<const MEDCoupling::MEDCouplingFieldDouble *>(li,SWIGTYPE_p_MEDCoupling__MEDCouplingFieldDouble,"MEDCouplingFieldDouble",tmp);
- int sz=tmp.size();
+ std::size_t sz=tmp.size();
std::vector<MEDCouplingFieldDouble *> fs(sz);
- for(int i=0;i<sz;i++)
+ for(std::size_t i=0;i<sz;i++)
fs[i]=const_cast<MEDCouplingFieldDouble *>(tmp[i]);
return MEDCouplingFieldOverTime::New(fs);
}
return self->simpleRepr();
}
static MEDCouplingFieldOverTime *New(PyObject *li)
- {
- std::vector<const MEDCoupling::MEDCouplingFieldDouble *> tmp;
- convertFromPyObjVectorOfObj<const MEDCoupling::MEDCouplingFieldDouble *>(li,SWIGTYPE_p_MEDCoupling__MEDCouplingFieldDouble,"MEDCouplingFieldDouble",tmp);
- int sz=tmp.size();
- std::vector<MEDCouplingFieldDouble *> fs(sz);
- for(int i=0;i<sz;i++)
- fs[i]=const_cast<MEDCouplingFieldDouble *>(tmp[i]);
- return MEDCouplingFieldOverTime::New(fs);
- }
+ {
+ std::vector<const MEDCoupling::MEDCouplingFieldDouble *> tmp;
+ convertFromPyObjVectorOfObj<const MEDCoupling::MEDCouplingFieldDouble *>(li,SWIGTYPE_p_MEDCoupling__MEDCouplingFieldDouble,"MEDCouplingFieldDouble",tmp);
+ std::size_t sz=tmp.size();
+ std::vector<MEDCouplingFieldDouble *> fs(sz);
+ for(std::size_t i=0;i<sz;i++)
+ fs[i]=const_cast<MEDCouplingFieldDouble *>(tmp[i]);
+ return MEDCouplingFieldOverTime::New(fs);
+ }
}
};
PyObject *getPatches() const
{
std::vector< const MEDCouplingCartesianAMRPatch *> ps(self->getPatches());
- mcIdType sz(ps.size());
+ std::size_t sz(ps.size());
PyObject *ret = PyList_New(sz);
- for(mcIdType i=0;i<sz;i++)
+ for(std::size_t i=0;i<sz;i++)
{
MEDCouplingCartesianAMRPatch *elt(const_cast<MEDCouplingCartesianAMRPatch *>(ps[i]));
if(elt)
virtual PyObject *retrieveGridsAt(mcIdType absoluteLev) const
{
std::vector<MEDCouplingCartesianAMRPatchGen *> ps(self->retrieveGridsAt(absoluteLev));
- mcIdType sz(ps.size());
+ std::size_t sz(ps.size());
PyObject *ret = PyList_New(sz);
- for(mcIdType i=0;i<sz;i++)
+ for(std::size_t i=0;i<sz;i++)
PyList_SetItem(ret,i,convertCartesianAMRPatch(ps[i], SWIG_POINTER_OWN | 0 ));
return ret;
}
#
# Forwarding DataArrayInt functions to MEDCouplingUMesh:
#
-MEDCouplingUMesh.ExtractFromIndexedArrays = DataArrayInt32.ExtractFromIndexedArrays
-MEDCouplingUMesh.ExtractFromIndexedArraysSlice = DataArrayInt32.ExtractFromIndexedArraysSlice
-MEDCouplingUMesh.SetPartOfIndexedArrays = DataArrayInt32.SetPartOfIndexedArrays
-##MEDCouplingUMesh.SetPartOfIndexedArraysSlice = DataArrayInt32.SetPartOfIndexedArraysSlice
-MEDCouplingUMesh.SetPartOfIndexedArraysSameIdx = DataArrayInt32.SetPartOfIndexedArraysSameIdx
-MEDCouplingUMesh.RemoveIdsFromIndexedArrays = DataArrayInt32.RemoveIdsFromIndexedArrays
-##MEDCouplingUMesh.SetPartOfIndexedArraysSameIdxSlice = DataArrayInt32.SetPartOfIndexedArraysSameIdxSlice
+MEDCouplingUMesh.ExtractFromIndexedArrays = DataArrayInt.ExtractFromIndexedArrays
+MEDCouplingUMesh.ExtractFromIndexedArraysSlice = DataArrayInt.ExtractFromIndexedArraysSlice
+MEDCouplingUMesh.SetPartOfIndexedArrays = DataArrayInt.SetPartOfIndexedArrays
+##MEDCouplingUMesh.SetPartOfIndexedArraysSlice = DataArrayInt.SetPartOfIndexedArraysSlice
+MEDCouplingUMesh.SetPartOfIndexedArraysSameIdx = DataArrayInt.SetPartOfIndexedArraysSameIdx
+MEDCouplingUMesh.RemoveIdsFromIndexedArrays = DataArrayInt.RemoveIdsFromIndexedArrays
+##MEDCouplingUMesh.SetPartOfIndexedArraysSameIdxSlice = DataArrayInt.SetPartOfIndexedArraysSameIdxSlice
%}
};
typedef struct PyCallBackDataArraySt<MEDCoupling::DataArrayByte> PyCallBackDataArrayChar;
-typedef struct PyCallBackDataArraySt<MEDCoupling::DataArrayInt> PyCallBackDataArrayInt;
+typedef struct PyCallBackDataArraySt<MEDCoupling::DataArrayInt32> PyCallBackDataArrayInt32;
+typedef struct PyCallBackDataArraySt<MEDCoupling::DataArrayInt64> PyCallBackDataArrayInt64;
typedef struct PyCallBackDataArraySt<MEDCoupling::DataArrayFloat> PyCallBackDataArrayFloat;
typedef struct PyCallBackDataArraySt<MEDCoupling::DataArrayDouble> PyCallBackDataArrayDouble;
return (PyObject *)self;
}
- static PyObject *callbackmcdataarrayint___new__(PyTypeObject *type, PyObject *args, PyObject *kwargs)
+ static PyObject *callbackmcdataarrayint32___new__(PyTypeObject *type, PyObject *args, PyObject *kwargs)
{
- PyCallBackDataArrayInt *self = (PyCallBackDataArrayInt *) ( type->tp_alloc(type, 0) );
+ PyCallBackDataArrayInt32 *self = (PyCallBackDataArrayInt32 *) ( type->tp_alloc(type, 0) );
+ return (PyObject *)self;
+ }
+
+ static PyObject *callbackmcdataarrayint64___new__(PyTypeObject *type, PyObject *args, PyObject *kwargs)
+ {
+ PyCallBackDataArrayInt64 *self = (PyCallBackDataArrayInt64 *) ( type->tp_alloc(type, 0) );
return (PyObject *)self;
}
// real callback called when a numpy arr having more than one DataArray instance client on it is destroyed.
// In this case, all the "weak" clients, except the first one, invoke this call back that desable the content of these "weak" clients.
- static PyObject *callbackmcdataarrayint_call(PyCallBackDataArrayInt *self, PyObject *args, PyObject *kw)
+ static PyObject *callbackmcdataarrayint32_call(PyCallBackDataArrayInt32 *self, PyObject *args, PyObject *kw)
{
if(self->_pt_mc)
{
return Py_None;
}
+ // real callback called when a numpy arr having more than one DataArray instance client on it is destroyed.
+ // In this case, all the "weak" clients, except the first one, invoke this call back that desable the content of these "weak" clients.
+ static PyObject *callbackmcdataarrayint64_call(PyCallBackDataArrayInt64 *self, PyObject *args, PyObject *kw)
+ {
+ if(self->_pt_mc)
+ {
+ MEDCoupling::MemArray<long>& mma=self->_pt_mc->accessToMemArray();
+ mma.destroy();
+ }
+ Py_XINCREF(Py_None);
+ return Py_None;
+ }
+
// real callback called when a numpy arr having more than one DataArray instance client on it is destroyed.
// In this case, all the "weak" clients, except the first one, invoke this call back that desable the content of these "weak" clients.
static PyObject *callbackmcdataarrayfloat_call(PyCallBackDataArrayFloat *self, PyObject *args, PyObject *kw)
};
-PyTypeObject PyCallBackDataArrayInt_RefType = {
+PyTypeObject PyCallBackDataArrayInt32_RefType = {
PyVarObject_HEAD_INIT(&PyType_Type, 0)
- "callbackmcdataarrayint",
- sizeof(PyCallBackDataArrayInt),
+ "callbackmcdataarrayint32",
+ sizeof(PyCallBackDataArrayInt32),
0,
callbackmcdataarray_dealloc, /*tp_dealloc*/
0, /*tp_print*/
0, /*tp_as_sequence*/
0, /*tp_as_mapping*/
0, /*tp_hash*/
- (ternaryfunc)callbackmcdataarrayint_call, /*tp_call*/
+ (ternaryfunc)callbackmcdataarrayint32_call, /*tp_call*/
0, /*tp_str*/
0, /*tp_getattro*/
0, /*tp_setattro*/
0, /*tp_dictoffset*/
callbackmcdataarray___init__, /*tp_init*/
PyType_GenericAlloc, /*tp_alloc*/
- callbackmcdataarrayint___new__, /*tp_new*/
+ callbackmcdataarrayint32___new__, /*tp_new*/
+ PyObject_GC_Del, /*tp_free*/
+};
+
+
+PyTypeObject PyCallBackDataArrayInt64_RefType = {
+ PyVarObject_HEAD_INIT(&PyType_Type, 0)
+ "callbackmcdataarrayint64",
+ sizeof(PyCallBackDataArrayInt64),
+ 0,
+ callbackmcdataarray_dealloc, /*tp_dealloc*/
+ 0, /*tp_print*/
+ 0, /*tp_getattr*/
+ 0, /*tp_setattr*/
+ 0, /*tp_compare*/
+ 0, /*tp_repr*/
+ 0, /*tp_as_number*/
+ 0, /*tp_as_sequence*/
+ 0, /*tp_as_mapping*/
+ 0, /*tp_hash*/
+ (ternaryfunc)callbackmcdataarrayint64_call, /*tp_call*/
+ 0, /*tp_str*/
+ 0, /*tp_getattro*/
+ 0, /*tp_setattro*/
+ 0, /*tp_as_buffer*/
+ Py_TPFLAGS_DEFAULT | Py_TPFLAGS_HAVE_GC | Py_TPFLAGS_BASETYPE, /*tp_flags*/
+ 0, /*tp_doc*/
+ 0, /*tp_traverse*/
+ 0, /*tp_clear*/
+ 0, /*tp_richcompare*/
+ 0, /*tp_weaklistoffset*/
+ 0, /*tp_iter*/
+ 0, /*tp_iternext*/
+ 0, /*tp_methods*/
+ 0, /*tp_members*/
+ 0, /*tp_getset*/
+ 0, /*tp_base*/
+ 0, /*tp_dict*/
+ 0, /*tp_descr_get*/
+ 0, /*tp_descr_set*/
+ 0, /*tp_dictoffset*/
+ callbackmcdataarray___init__, /*tp_init*/
+ PyType_GenericAlloc, /*tp_alloc*/
+ callbackmcdataarrayint64___new__, /*tp_new*/
PyObject_GC_Del, /*tp_free*/
};
static PyTypeObject *NPYFunc;
static PyObject *Array_SWIGTYPE;
};
+
+template<>
+struct NPYTraits<int>
+{
+ static const int NPYObjectType=NPY_INT32;
+ static PyTypeObject *NPYFunc;
+ static PyObject *Array_SWIGTYPE;
+};
+
+template<>
+struct NPYTraits<long>
+{
+ static const int NPYObjectType=NPY_INT64;
+ static PyTypeObject *NPYFunc;
+ static PyObject *Array_SWIGTYPE;
+};
#endif
#endif
throw INTERP_KERNEL::Exception(msgInCaseOfFailure);
}
-int InterpreteNegativeInt(int val, int nbelem)
+int InterpreteNegativeInt(long val, mcIdType nbelem)
{
if(val<0)
{
- int newVal(nbelem+val);
+ int newVal((int)(nbelem+val));
if(newVal<0)
{
std::ostringstream oss; oss << "interpreteNegativeInt : request for negative int=" << val << " but number of elems is equal to " << nbelem << " !";
return newVal;
}
else
- return val;
+ return (int)val;
}
#ifdef WITH_NUMPY
if(PyArray_DESCR(elt0)->type_num != npyObjectType)
{
std::ostringstream oss; oss << "Input numpy array has not the type " << msg << "!";
+#ifdef _DEBUG_
+ oss << " type_num == " << PyArray_DESCR(elt0)->type_num;
+#endif
throw INTERP_KERNEL::Exception(oss.str().c_str());
}
npy_intp sz0=PyArray_DIM(elt0,0);
}
template<class MCData, class T>
-PyObject *ToNumPyArrayUnderground(MCData *self, int npyObjectType, const char *MCDataStr, int nbTuples, int nbComp)
+PyObject *ToNumPyArrayUnderground(MCData *self, int npyObjectType, const char *MCDataStr, mcIdType nbTuples, std::size_t nbComp)
{
if(!self->isAllocated())
{
}
int nbDims=nbComp==1?1:2;
npy_intp dim[2];
- dim[0]=(npy_intp)nbTuples; dim[1]=nbComp;
+ dim[0]=(npy_intp)nbTuples; dim[1]=(npy_intp)nbComp;
const T *bg=self->getConstPointer();
PyObject *ret(PyArray_SimpleNewFromData(nbDims,dim,npyObjectType,const_cast<T *>(bg)));
if(mem.isDeallocatorCalled())
template<class T>
static PyObject *convertIntArrToPyList2(const std::vector<T>& v)
{
- T size=v.size();
+ std::size_t size=v.size();
PyObject *ret=PyList_New(size);
- for(T i=0;i<size;i++)
+ for(std::size_t i=0;i<size;i++)
PyList_SetItem(ret,i,PyInt_FromLong(v[i]));
return ret;
}
template<class T>
static PyObject *convertIntArrToPyList3(const std::set<T>& v)
{
- T size=v.size();
+ std::size_t size=v.size();
PyObject *ret=PyList_New(size);
typename std::set<T>::const_iterator it=v.begin();
- for(T i=0;i<size;i++,it++)
+ for(std::size_t i=0;i<size;i++,it++)
PyList_SetItem(ret,i,PyInt_FromLong(*it));
return ret;
}
{
if(PyList_Check(pyLi))
{
- *size=PyList_Size(pyLi);
+ *size=ToIdType(PyList_Size(pyLi));
T *tmp=new T[*size];
for(mcIdType i=0;i<*size;i++)
{
}
else if(PyTuple_Check(pyLi))
{
- *size=PyTuple_Size(pyLi);
+ *size=ToIdType(PyTuple_Size(pyLi));
T *tmp=new T[*size];
for(mcIdType i=0;i<*size;i++)
{
const char msg[]="list must contain tuples of 2 integers only or tuple must contain tuples of 2 integers only !";
if(PyList_Check(pyLi))
{
- mcIdType size=PyList_Size(pyLi);
+ std::size_t size=PyList_Size(pyLi);
arr.resize(size);
- for(mcIdType i=0;i<size;i++)
+ for(std::size_t i=0;i<size;i++)
{
PyObject *o=PyList_GetItem(pyLi,i);
if(PyTuple_Check(o))
{
- mcIdType sz2=PyTuple_Size(o);
+ std::size_t sz2=PyTuple_Size(o);
if(sz2!=2)
throw INTERP_KERNEL::Exception(msg);
PyObject *o_0=PyTuple_GetItem(o,0);
}
else if(PyTuple_Check(pyLi))
{
- mcIdType size=PyTuple_Size(pyLi);
+ std::size_t size=PyTuple_Size(pyLi);
arr.resize(size);
- for(mcIdType i=0;i<size;i++)
+ for(std::size_t i=0;i<size;i++)
{
PyObject *o=PyTuple_GetItem(pyLi,i);
if(PyTuple_Check(o))
{
- mcIdType sz2=PyTuple_Size(o);
+ std::size_t sz2=PyTuple_Size(o);
if(sz2!=2)
throw INTERP_KERNEL::Exception(msg);
PyObject *o_0=PyTuple_GetItem(o,0);
const char msg[]="convertPyToVectorPairStringInt : list must contain tuples of 2 integers only or tuple must contain tuples of 1 string and 1 integer only !";
if(PyList_Check(pyLi))
{
- mcIdType size=PyList_Size(pyLi);
+ std::size_t size=PyList_Size(pyLi);
arr.resize(size);
- for(mcIdType i=0;i<size;i++)
+ for(std::size_t i=0;i<size;i++)
{
PyObject *o=PyList_GetItem(pyLi,i);
if(PyTuple_Check(o))
{
- mcIdType sz2=PyTuple_Size(o);
+ std::size_t sz2=PyTuple_Size(o);
if(sz2!=2)
throw INTERP_KERNEL::Exception(msg);
PyObject *o_0=PyTuple_GetItem(o,0);
arr[i].first=convertPyObjectToStr(o_0,msg);
if(!PyInt_Check(o_1))
throw INTERP_KERNEL::Exception(msg);
- arr[i].second=(mcIdType)PyInt_AS_LONG(o_1);
+ arr[i].second=(int)PyInt_AS_LONG(o_1);
}
else
throw INTERP_KERNEL::Exception(msg);
}
else if(PyTuple_Check(pyLi))
{
- mcIdType size=PyTuple_Size(pyLi);
+ std::size_t size=PyTuple_Size(pyLi);
arr.resize(size);
- for(mcIdType i=0;i<size;i++)
+ for(std::size_t i=0;i<size;i++)
{
PyObject *o=PyTuple_GetItem(pyLi,i);
if(PyTuple_Check(o))
{
- mcIdType sz2=PyTuple_Size(o);
+ std::size_t sz2=PyTuple_Size(o);
if(sz2!=2)
throw INTERP_KERNEL::Exception(msg);
PyObject *o_0=PyTuple_GetItem(o,0);
arr[i].first=convertPyObjectToStr(o_0,msg);
if(!PyInt_Check(o_1))
throw INTERP_KERNEL::Exception(msg);
- arr[i].second=(mcIdType)PyInt_AS_LONG(o_1);
+ arr[i].second=(int)PyInt_AS_LONG(o_1);
}
else
throw INTERP_KERNEL::Exception(msg);
arr.clear();
if(PyList_Check(pyLi))
{
- mcIdType size=PyList_Size(pyLi);
- for(mcIdType i=0;i<size;i++)
+ std::size_t size=PyList_Size(pyLi);
+ for(std::size_t i=0;i<size;i++)
{
PyObject *o=PyList_GetItem(pyLi,i);
if(PyInt_Check(o))
}
else if(PyTuple_Check(pyLi))
{
- mcIdType size=PyTuple_Size(pyLi);
- for(mcIdType i=0;i<size;i++)
+ std::size_t size=PyTuple_Size(pyLi);
+ for(std::size_t i=0;i<size;i++)
{
PyObject *o=PyTuple_GetItem(pyLi,i);
if(PyInt_Check(o))
{
- mcIdType val=(int)PyInt_AS_LONG(o);
+ mcIdType val=ToIdType(PyInt_AS_LONG(o));
arr.push_back(val);
}
else
static const char MSG[]="fillArrayWithPyListInt3 : It appears that the input list or tuple is composed by elts having different sizes !";
if(PyInt_Check(pyLi))
{
- T val=PyInt_AS_LONG(pyLi);
+ T val=(T)PyInt_AS_LONG(pyLi);
if(nbOfElt==-1)
nbOfElt=1;
else
}
else if(PyList_Check(pyLi))
{
- mcIdType size=PyList_Size(pyLi);
+ std::size_t size=PyList_Size(pyLi);
mcIdType tmp=0;
- for(mcIdType i=0;i<size;i++)
+ for(std::size_t i=0;i<size;i++)
{
PyObject *o=PyList_GetItem(pyLi,i);
mcIdType tmp1=-1;
}
else if(PyTuple_Check(pyLi))
{
- mcIdType size=PyTuple_Size(pyLi);
+ std::size_t size=PyTuple_Size(pyLi);
mcIdType tmp=0;
- for(mcIdType i=0;i<size;i++)
+ for(std::size_t i=0;i<size;i++)
{
PyObject *o=PyTuple_GetItem(pyLi,i);
mcIdType tmp1=-1;
mcIdType size1=-1,size2=-1;
if(PyList_Check(pyLi))
{
- size1=PyList_Size(pyLi);
+ size1=ToIdType(PyList_Size(pyLi));
for(mcIdType i=0;i<size1;i++)
{
PyObject *o=PyList_GetItem(pyLi,i);
}
else if(PyTuple_Check(pyLi))
{
- size1=PyTuple_Size(pyLi);
+ size1=ToIdType(PyTuple_Size(pyLi));
for(mcIdType i=0;i<size1;i++)
{
PyObject *o=PyTuple_GetItem(pyLi,i);
{
PyObject *o=PyList_GetItem(pyLi,i);
if(PyInt_Check(o))
- vec[i]=PyInt_AS_LONG(o);
+ vec[i]=ToIdType(PyInt_AS_LONG(o));
else
return false;
}
{
PyObject *o=PyTuple_GetItem(pyLi,i);
if(PyInt_Check(o))
- vec[i]=PyInt_AS_LONG(o);
+ vec[i]=ToIdType(PyInt_AS_LONG(o));
else
return false;
}
PyObject *o=PyList_GetItem(pyLi,i);
if(PyTuple_Check(o))
{
- mcIdType sz2=PyTuple_Size(o);
+ std::size_t sz2=PyTuple_Size(o);
if(sz2!=2)
throw INTERP_KERNEL::Exception(msg);
std::pair<std::string, std::vector<std::string> > item;
{
Py_ssize_t sz=PyTuple_Size(pyLi);
arr.resize(sz);
- for(mcIdType i=0;i<sz;i++)
+ for(Py_ssize_t i=0;i<sz;i++)
{
PyObject *o=PyTuple_GetItem(pyLi,i);
if(PyTuple_Check(o))
{
- mcIdType sz2=PyTuple_Size(o);
+ std::size_t sz2=PyTuple_Size(o);
if(sz2!=2)
throw INTERP_KERNEL::Exception(msg);
std::pair<std::string, std::vector<std::string> > item;
}
template<class T>
-PyObject *convertDblArrToPyList(const T *ptr, mcIdType size)
+PyObject *convertDblArrToPyList(const T *ptr, std::size_t size)
{
PyObject *ret(PyList_New(size));
- for(mcIdType i=0;i<size;i++)
+ for(std::size_t i=0;i<size;i++)
PyList_SetItem(ret,i,PyFloat_FromDouble(ptr[i]));
return ret;
}
static PyObject *convertDblArrToPyList2(const std::vector<double>& v)
{
- mcIdType size(v.size());
+ std::size_t size(v.size());
PyObject *ret(PyList_New(size));
- for(mcIdType i=0;i<size;i++)
+ for(std::size_t i=0;i<size;i++)
PyList_SetItem(ret,i,PyFloat_FromDouble(v[i]));
return ret;
}
template<class T>
-PyObject *convertDblArrToPyListOfTuple(const T *vals, int nbOfComp, mcIdType nbOfTuples)
+PyObject *convertDblArrToPyListOfTuple(const T *vals, std::size_t nbOfComp, mcIdType nbOfTuples)
{
PyObject *ret(PyList_New(nbOfTuples));
for(mcIdType i=0;i<nbOfTuples;i++)
{
PyObject *t=PyTuple_New(nbOfComp);
- for(mcIdType j=0;j<nbOfComp;j++)
+ for(std::size_t j=0;j<nbOfComp;j++)
PyTuple_SetItem(t,j,PyFloat_FromDouble(vals[i*nbOfComp+j]));
PyList_SetItem(ret,i,t);
}
{
if(PyList_Check(pyLi))
{
- *size=PyList_Size(pyLi);
+ *size=ToIdType(PyList_Size(pyLi));
double *tmp=(double *)malloc((*size)*sizeof(double));
for(mcIdType i=0;i<*size;i++)
{
}
else if(PyInt_Check(o))
{
- mcIdType val0=PyInt_AS_LONG(o);
- double val=val0;
+ long val0=PyInt_AS_LONG(o);
+ double val=(double)val0;
tmp[i]=val;
}
else
}
else if(PyTuple_Check(pyLi))
{
- *size=PyTuple_Size(pyLi);
+ *size=ToIdType(PyTuple_Size(pyLi));
double *tmp=(double *)malloc((*size)*sizeof(double));
for(mcIdType i=0;i<*size;i++)
{
}
else if(PyInt_Check(o))
{
- mcIdType val0=PyInt_AS_LONG(o);
- double val=val0;
+ long val0=PyInt_AS_LONG(o);
+ double val=(double)val0;
tmp[i]=val;
}
else
}
else if(PyInt_Check(pyLi))
{
- mcIdType val0=PyInt_AS_LONG(pyLi);
- double val=val0;
+ mcIdType val0=ToIdType(PyInt_AS_LONG(pyLi));
+ double val=(double)val0;
if(nbOfElt==-1)
nbOfElt=1;
else
}
else if(PyList_Check(pyLi))
{
- mcIdType size=PyList_Size(pyLi);
+ std::size_t size=PyList_Size(pyLi);
mcIdType tmp=0;
- for(mcIdType i=0;i<size;i++)
+ for(std::size_t i=0;i<size;i++)
{
PyObject *o=PyList_GetItem(pyLi,i);
mcIdType tmp1=-1;
}
else if(PyTuple_Check(pyLi))
{
- mcIdType size=PyTuple_Size(pyLi);
+ std::size_t size=PyTuple_Size(pyLi);
mcIdType tmp=0;
- for(mcIdType i=0;i<size;i++)
+ for(std::size_t i=0;i<size;i++)
{
PyObject *o=PyTuple_GetItem(pyLi,i);
mcIdType tmp1=-1;
static std::vector<double> fillArrayWithPyListDbl2(PyObject *pyLi, mcIdType& nbOfTuples, mcIdType& nbOfComp)
{
std::vector<double> ret;
- mcIdType size1=-1,size2=-1;
+ std::size_t size1=-1;
+ mcIdType size2=-1;
if(PyList_Check(pyLi))
{
size1=PyList_Size(pyLi);
- for(mcIdType i=0;i<size1;i++)
+ for(std::size_t i=0;i<size1;i++)
{
PyObject *o=PyList_GetItem(pyLi,i);
fillArrayWithPyListDbl3(o,size2,ret);
else if(PyTuple_Check(pyLi))
{
size1=PyTuple_Size(pyLi);
- for(mcIdType i=0;i<size1;i++)
+ for(std::size_t i=0;i<size1;i++)
{
PyObject *o=PyTuple_GetItem(pyLi,i);
fillArrayWithPyListDbl3(o,size2,ret);
else
throw INTERP_KERNEL::Exception("fillArrayWithPyListDbl2 : Unrecognized type ! Should be a tuple or a list !");
//
- checkFillArrayWithPyList(size1,size2,nbOfTuples,nbOfComp);
+ checkFillArrayWithPyList(ToIdType(size1),ToIdType(size2),nbOfTuples,nbOfComp);
return ret;
}
void *argp=0;
if(PyList_Check(pyLi))
{
- mcIdType size=PyList_Size(pyLi);
+ std::size_t size=PyList_Size(pyLi);
ret.resize(size);
- for(mcIdType i=0;i<size;i++)
+ for(std::size_t i=0;i<size;i++)
{
PyObject *obj=PyList_GetItem(pyLi,i);
int status=SWIG_ConvertPtr(obj,&argp,ty,0|0);
}
else if(PyTuple_Check(pyLi))
{
- mcIdType size=PyTuple_Size(pyLi);
+ std::size_t size=PyTuple_Size(pyLi);
ret.resize(size);
- for(mcIdType i=0;i<size;i++)
+ for(std::size_t i=0;i<size;i++)
{
PyObject *obj=PyTuple_GetItem(pyLi,i);
int status=SWIG_ConvertPtr(obj,&argp,ty,0|0);
}
if(PyTuple_Check(value))
{
- mcIdType size=PyTuple_Size(value);
+ std::size_t size=PyTuple_Size(value);
stdvecTyypp.resize(size);
- for(mcIdType i=0;i<size;i++)
+ for(std::size_t i=0;i<size;i++)
{
PyObject *o=PyTuple_GetItem(value,i);
if(PyInt_Check(o))
}
if(PyList_Check(value))
{
- mcIdType size=PyList_Size(value);
+ std::size_t size=PyList_Size(value);
stdvecTyypp.resize(size);
- for(mcIdType i=0;i<size;i++)
+ for(std::size_t i=0;i<size;i++)
{
PyObject *o=PyList_GetItem(value,i);
if(PyInt_Check(o))
}
if(PyTuple_Check(value))
{
- mcIdType size=PyTuple_Size(value);
+ std::size_t size=PyTuple_Size(value);
stdvecTyypp.resize(size);
- for(mcIdType i=0;i<size;i++)
+ for(std::size_t i=0;i<size;i++)
{
PyObject *o=PyTuple_GetItem(value,i);
if(PyInt_Check(o))
throw INTERP_KERNEL::Exception(oss.str().c_str());
}
}
- sw=2; sz=size;
+ sw=2; sz=ToIdType(size);
return &stdvecTyypp[0];
}
if(PyList_Check(value))
{
- mcIdType size=PyList_Size(value);
+ std::size_t size=PyList_Size(value);
stdvecTyypp.resize(size);
- for(mcIdType i=0;i<size;i++)
+ for(std::size_t i=0;i<size;i++)
{
PyObject *o=PyList_GetItem(value,i);
if(PyInt_Check(o))
throw INTERP_KERNEL::Exception(oss.str().c_str());
}
}
- sw=2; sz=size;
+ sw=2; sz=ToIdType(size);
return &stdvecTyypp[0];
}
void *argp;
{
typedef typename MEDCoupling::Traits< T >::ArrayTuple ARRAYTUPLE;
ARRAYTUPLE *daIntTuple=reinterpret_cast< ARRAYTUPLE * >(argp);
- sw=4; sz=daIntTuple->getNumberOfCompo();
+ sw=4; sz=ToIdType(daIntTuple->getNumberOfCompo());
return daIntTuple->getConstPointer();
}
throw INTERP_KERNEL::Exception("5 types accepted : integer, tuple of integer, list of integer, DataArrayIdType, DataArrayIdTypeTuple");
}
if(PyTuple_Check(value))
{
- mcIdType size=PyTuple_Size(value);
+ std::size_t size=PyTuple_Size(value);
stdvecTyypp.resize(size);
- for(mcIdType i=0;i<size;i++)
+ for(std::size_t i=0;i<size;i++)
{
PyObject *o=PyTuple_GetItem(value,i);
if(PyFloat_Check(o))
}
if(PyList_Check(value))
{
- mcIdType size=PyList_Size(value);
+ std::size_t size=PyList_Size(value);
stdvecTyypp.resize(size);
- for(mcIdType i=0;i<size;i++)
+ for(std::size_t i=0;i<size;i++)
{
PyObject *o=PyList_GetItem(value,i);
if(PyFloat_Check(o))
}
if(PyTuple_Check(value))
{
- mcIdType size=PyTuple_Size(value);
+ std::size_t size=PyTuple_Size(value);
stdvecTyypp.resize(size);
- for(mcIdType i=0;i<size;i++)
+ for(std::size_t i=0;i<size;i++)
{
PyObject *o=PyTuple_GetItem(value,i);
if(PyFloat_Check(o))
}
if(PyList_Check(value))
{
- mcIdType size=PyList_Size(value);
+ std::size_t size=PyList_Size(value);
stdvecTyypp.resize(size);
- for(mcIdType i=0;i<size;i++)
+ for(std::size_t i=0;i<size;i++)
{
PyObject *o=PyList_GetItem(value,i);
if(PyFloat_Check(o))
sw=-1;
if(PyFloat_Check(value))
{
- val=PyFloat_AS_DOUBLE(value);
+ val=(T)PyFloat_AS_DOUBLE(value);
sw=1;
return;
}
}
if(PyTuple_Check(value))
{
- mcIdType size=PyTuple_Size(value);
+ std::size_t size=PyTuple_Size(value);
f.resize(size);
- for(mcIdType i=0;i<size;i++)
+ for(std::size_t i=0;i<size;i++)
{
PyObject *o=PyTuple_GetItem(value,i);
if(PyFloat_Check(o))
- f[i]=PyFloat_AS_DOUBLE(o);
+ f[i]=(T)PyFloat_AS_DOUBLE(o);
else if(PyInt_Check(o))
f[i]=(T)PyInt_AS_LONG(o);
else
}
if(PyList_Check(value))
{
- mcIdType size=PyList_Size(value);
+ std::size_t size=PyList_Size(value);
f.resize(size);
- for(mcIdType i=0;i<size;i++)
+ for(std::size_t i=0;i<size;i++)
{
PyObject *o=PyList_GetItem(value,i);
if(PyFloat_Check(o))
- f[i]=PyFloat_AS_DOUBLE(o);
+ f[i]=(T)PyFloat_AS_DOUBLE(o);
else if(PyInt_Check(o))
f[i]=(T)PyInt_AS_LONG(o);
else
sw=-1;
if(PyInt_Check(value))
{
- iTyypp=(mcIdType)PyInt_AS_LONG(value);
+ iTyypp=(T)PyInt_AS_LONG(value);
sw=1;
return;
}
if(PyTuple_Check(value))
{
- mcIdType size=PyTuple_Size(value);
+ std::size_t size=PyTuple_Size(value);
stdvecTyypp.resize(size);
- for(mcIdType i=0;i<size;i++)
+ for(std::size_t i=0;i<size;i++)
{
PyObject *o=PyTuple_GetItem(value,i);
if(PyInt_Check(o))
- stdvecTyypp[i]=(mcIdType)PyInt_AS_LONG(o);
+ stdvecTyypp[i]=(T)PyInt_AS_LONG(o);
else
{
std::ostringstream oss; oss << "Tuple as been detected but element #" << i << " is not integer ! only tuples of integers accepted !";
}
if(PyList_Check(value))
{
- mcIdType size=PyList_Size(value);
+ std::size_t size=PyList_Size(value);
stdvecTyypp.resize(size);
- for(mcIdType i=0;i<size;i++)
+ for(std::size_t i=0;i<size;i++)
{
PyObject *o=PyList_GetItem(value,i);
if(PyInt_Check(o))
- stdvecTyypp[i]=(mcIdType)PyInt_AS_LONG(o);
+ stdvecTyypp[i]=(T)PyInt_AS_LONG(o);
else
{
std::ostringstream oss; oss << "List as been detected but element #" << i << " is not integer ! only lists of integers accepted !";
{
Py_ssize_t strt=2,stp=2,step=2;
GetIndicesOfSlice(value,nbelem,&strt,&stp,&step,"Slice in subscriptable object DataArray invalid !");
- p.first=strt;
- p.second.first=stp;
- p.second.second=step;
+ p.first=ToIdType(strt);
+ p.second.first=ToIdType(stp);
+ p.second.second=ToIdType(step);
sw=3;
return ;
}
convertIntStarOrSliceLikePyObjToCpp(value,nbelem,sw,iTyypp,stdvecTyypp,p,daIntTyypp);
if(sw==1)
{
- iTyypp=InterpreteNegativeInt(iTyypp,nbelem);
+ iTyypp=(T)InterpreteNegativeInt(iTyypp,nbelem);
}
}
sw=-1;
if(PyInt_Check(value))
{
- iTyypp=(mcIdType)PyInt_AS_LONG(value);
+ iTyypp=ToIdType(PyInt_AS_LONG(value));
sw=1;
return;
}
if(PyTuple_Check(value))
{
- mcIdType size=PyTuple_Size(value);
+ std::size_t size=PyTuple_Size(value);
stdvecTyypp.resize(size);
- for(mcIdType i=0;i<size;i++)
+ for(std::size_t i=0;i<size;i++)
{
PyObject *o=PyTuple_GetItem(value,i);
if(PyInt_Check(o))
}
if(PyList_Check(value))
{
- mcIdType size=PyList_Size(value);
+ std::size_t size=PyList_Size(value);
stdvecTyypp.resize(size);
- for(mcIdType i=0;i<size;i++)
+ for(std::size_t i=0;i<size;i++)
{
PyObject *o=PyList_GetItem(value,i);
if(PyInt_Check(o))
{
Py_ssize_t strt=2,stp=2,step=2;
GetIndicesOfSlice(value,nbelem,&strt,&stp,&step,"Slice in subscriptable object DataArray invalid !");
- p.first=strt;
- p.second.first=stp;
- p.second.second=step;
+ p.first=ToIdType(strt);
+ p.second.first=ToIdType(stp);
+ p.second.second=ToIdType(step);
sw=3;
return ;
}
#endif
if(PyTuple_Check(value))
{
- mcIdType size=PyTuple_Size(value);
+ std::size_t size=PyTuple_Size(value);
vsType.resize(size);
- for(mcIdType i=0;i<size;i++)
+ for(std::size_t i=0;i<size;i++)
{
PyObject *o=PyTuple_GetItem(value,i);
try
}
if(PyList_Check(value))
{
- mcIdType size=PyList_Size(value);
+ std::size_t size=PyList_Size(value);
vsType.resize(size);
- for(mcIdType i=0;i<size;i++)
+ for(std::size_t i=0;i<size;i++)
{
PyObject *o=PyList_GetItem(value,i);
try
}
else
{
- mcIdType sz=PyTuple_Size(value);
+ std::size_t sz=PyTuple_Size(value);
if(sz!=2)
throw INTERP_KERNEL::Exception("Unexpected nb of slice element : 1 or 2 expected !\n1st is for tuple selection, 2nd for component selection !");
PyObject *ob0=PyTuple_GetItem(value,0);
}
if(PyTuple_Check(value))
{
- mcIdType size=PyTuple_Size(value);
+ std::size_t size=PyTuple_Size(value);
f.resize(size);
- for(mcIdType i=0;i<size;i++)
+ for(std::size_t i=0;i<size;i++)
{
PyObject *o=PyTuple_GetItem(value,i);
if(PyFloat_Check(o))
std::ostringstream oss; oss << msg << "dimension expected to be a multiple of " << nbCompExpected << " , and your data in input has dimension " << f.size() << " !";
throw INTERP_KERNEL::Exception(oss.str().c_str());
}
- nbTuples=size/nbCompExpected;
+ nbTuples=ToIdType(size/nbCompExpected);
return &f[0];
}
if(PyList_Check(value))
{
- mcIdType size=PyList_Size(value);
+ std::size_t size=PyList_Size(value);
f.resize(size);
- for(mcIdType i=0;i<size;i++)
+ for(std::size_t i=0;i<size;i++)
{
PyObject *o=PyList_GetItem(value,i);
if(PyFloat_Check(o))
std::ostringstream oss; oss << msg << "dimension expected to be a multiple of " << nbCompExpected << " , and your data in input has dimension " << f.size() << " !";
throw INTERP_KERNEL::Exception(oss.str().c_str());
}
- nbTuples=size/nbCompExpected;
+ nbTuples=ToIdType(size/nbCompExpected);
return &f[0];
}
void *argp;
}
if(PyTuple_Check(value))
{
- mcIdType size=PyTuple_Size(value);
+ std::size_t size=PyTuple_Size(value);
f.resize(size);
- for(mcIdType i=0;i<size;i++)
+ for(std::size_t i=0;i<size;i++)
{
PyObject *o=PyTuple_GetItem(value,i);
if(PyFloat_Check(o))
}
}
sw=4;
- nbTuples=size;
+ nbTuples=ToIdType(size);
return &f[0];
}
if(PyList_Check(value))
{
- mcIdType size=PyList_Size(value);
+ std::size_t size=PyList_Size(value);
f.resize(size);
- for(mcIdType i=0;i<size;i++)
+ for(std::size_t i=0;i<size;i++)
{
PyObject *o=PyList_GetItem(value,i);
if(PyFloat_Check(o))
}
}
sw=4;
- nbTuples=size;
+ nbTuples=ToIdType(size);
return &f[0];
}
void *argp;
sw=3;
if(e)
{
- nbTuples=e->getNumberOfCompo();
+ nbTuples=ToIdType(e->getNumberOfCompo());
return e->getConstPointer();
}
else
{
if(PyInt_Check(nbOfTuples))
{
- mcIdType nbOfTuples1=PyInt_AS_LONG(nbOfTuples);
+ mcIdType nbOfTuples1=ToIdType(PyInt_AS_LONG(nbOfTuples));
if(nbOfTuples1<0)
throw INTERP_KERNEL::Exception("DataArrayDouble::New : should be a positive set of allocated memory !");
if(elt2)
{
if(PyInt_Check(elt2))
{//DataArrayDouble.New([1.,3.,4.,5.],2,2)
- mcIdType nbOfCompo=PyInt_AS_LONG(elt2);
+ mcIdType nbOfCompo=ToIdType(PyInt_AS_LONG(elt2));
if(nbOfCompo<0)
throw INTERP_KERNEL::Exception("DataArrayDouble::New : should be a positive number of components !");
MEDCoupling::MCAuto< typename MEDCoupling::Traits<T>::ArrayType > ret(MEDCoupling::Traits<T>::ArrayType::New());
}
else if(PyInt_Check(elt0))
{
- mcIdType nbOfTuples1(PyInt_AS_LONG(elt0));
+ mcIdType nbOfTuples1(ToIdType(PyInt_AS_LONG(elt0)));
if(nbOfTuples1<0)
throw INTERP_KERNEL::Exception("DataArrayDouble::New : should be a positive set of allocated memory !");
if(nbOfTuples)
{
if(PyInt_Check(nbOfTuples))
{//DataArrayDouble.New(5,2)
- mcIdType nbOfCompo=PyInt_AS_LONG(nbOfTuples);
+ mcIdType nbOfCompo=ToIdType(PyInt_AS_LONG(nbOfTuples));
if(nbOfCompo<0)
throw INTERP_KERNEL::Exception("DataArrayDouble::New : should be a positive number of components !");
MEDCoupling::MCAuto< typename MEDCoupling::Traits<T>::ArrayType > ret(MEDCoupling::Traits<T>::ArrayType::New());
{
self->checkAllocated();
const char msg[]="Unexpected situation in DataArrayDouble::__setitem__ !";
- mcIdType nbOfTuples(self->getNumberOfTuples()),nbOfComponents(self->getNumberOfComponents());
+ mcIdType nbOfTuples(self->getNumberOfTuples());
+ int nbOfComponents((int)(self->getNumberOfComponents()));
mcIdType sw1,sw2;
T i1;
std::vector<T> v1;
const char msg[]="Unexpected situation in DataArrayDouble::__getitem__ !";
const char msg2[]="DataArrayDouble::__getitem__ : Mismatch of slice values in 2nd parameter (components) !";
self->checkAllocated();
- mcIdType nbOfTuples(self->getNumberOfTuples()),nbOfComponents(self->getNumberOfComponents());
+ mcIdType nbOfTuples(self->getNumberOfTuples());
+ int nbOfComponents((int)(self->getNumberOfComponents()));
mcIdType it1;
std::size_t ic1;
std::vector<mcIdType> vt1;
case 13:
{
ret=self->selectByTupleIdSafe(&it1,&it1+1);
- int nbOfComp(MEDCoupling::DataArray::GetNumberOfItemGivenBESRelative(pc1.first,pc1.second.first,pc1.second.second,msg2));
+ mcIdType nbOfComp(MEDCoupling::DataArray::GetNumberOfItemGivenBESRelative(pc1.first,pc1.second.first,pc1.second.second,msg2));
std::vector<std::size_t> v2(nbOfComp);
for(mcIdType i=0;i<nbOfComp;i++)
v2[i]=pc1.first+i*pc1.second.second;
case 14:
{
ret=self->selectByTupleIdSafe(&vt1[0],&vt1[0]+vt1.size());
- int nbOfComp(MEDCoupling::DataArray::GetNumberOfItemGivenBESRelative(pc1.first,pc1.second.first,pc1.second.second,msg2));
+ mcIdType nbOfComp(MEDCoupling::DataArray::GetNumberOfItemGivenBESRelative(pc1.first,pc1.second.first,pc1.second.second,msg2));
std::vector<std::size_t> v2(nbOfComp);
for(int i=0;i<nbOfComp;i++)
v2[i]=pc1.first+i*pc1.second.second;
case 15:
{
ret=self->selectByTupleIdSafeSlice(pt1.first,pt1.second.first,pt1.second.second);
- int nbOfComp(MEDCoupling::DataArray::GetNumberOfItemGivenBESRelative(pc1.first,pc1.second.first,pc1.second.second,msg2));
+ mcIdType nbOfComp(MEDCoupling::DataArray::GetNumberOfItemGivenBESRelative(pc1.first,pc1.second.first,pc1.second.second,msg2));
std::vector<std::size_t> v2(nbOfComp);
for(int i=0;i<nbOfComp;i++)
v2[i]=pc1.first+i*pc1.second.second;
case 16:
{
ret=self->selectByTupleIdSafe(dt1->getConstPointer(),dt1->getConstPointer()+dt1->getNbOfElems());
- int nbOfComp(MEDCoupling::DataArray::GetNumberOfItemGivenBESRelative(pc1.first,pc1.second.first,pc1.second.second,msg2));
+ mcIdType nbOfComp(MEDCoupling::DataArray::GetNumberOfItemGivenBESRelative(pc1.first,pc1.second.first,pc1.second.second,msg2));
std::vector<std::size_t> v2(nbOfComp);
for(int i=0;i<nbOfComp;i++)
v2[i]=pc1.first+i*pc1.second.second;
#endif
}
-void convertCSR_MCDataToVectMapIntDouble(const MEDCoupling::DataArrayIdType *indptrPtr, const MEDCoupling::DataArrayIdType *indicesPtr, const MEDCoupling::DataArrayDouble *dataPtr, std::vector<std::map<mcIdType,double> >& mCpp)
+void convertCSR_MCDataToVectMapIntDouble(const MEDCoupling::DataArrayInt32 *indptrPtr, const MEDCoupling::DataArrayInt32 *indicesPtr, const MEDCoupling::DataArrayDouble *dataPtr, std::vector<std::map<mcIdType,double> >& mCpp)
{
auto nbOfRows(indptrPtr->getNumberOfTuples()-1);
if(nbOfRows<0)
std::ostringstream oss; oss << "convertToVectMapIntDouble : at pos # " << i << " of pylist the dict contains at pos " << pos << " the value not mappable to pyfloat !";
throw INTERP_KERNEL::Exception(oss.str());
}
- mapCpp[(mcIdType)PyInt_AS_LONG(key)]=PyFloat_AS_DOUBLE(value);
+ mapCpp[ToIdType(PyInt_AS_LONG(key))]=PyFloat_AS_DOUBLE(value);
}
}
}
{
if(val==0.)
throw INTERP_KERNEL::Exception("DataArrayDouble::__div__ : trying to divide by zero !");
- self->applyLin(1./val,0.);
+ self->applyLin((T)(1./val),(T)0.);
Py_XINCREF(trueSelf);
return trueSelf;
}
PyTypeObject *NPYTraits<double>::NPYFunc=&PyCallBackDataArrayDouble_RefType;
PyTypeObject *NPYTraits<float>::NPYFunc=&PyCallBackDataArrayFloat_RefType;
+
+PyTypeObject *NPYTraits<int>::NPYFunc=&PyCallBackDataArrayInt32_RefType;
+
+PyTypeObject *NPYTraits<long>::NPYFunc=&PyCallBackDataArrayInt64_RefType;
#endif
template<class T>
{
if(!arr)
throw INTERP_KERNEL::Exception("wrap of MEDCouplingFieldDiscretization::normL1 : input array is null !");
- int sz(arr->getNumberOfComponents());
+ std::size_t sz(arr->getNumberOfComponents());
INTERP_KERNEL::AutoPtr<double> tmp=new double[sz];
self->normL1(mesh,arr,tmp);
return convertDblArrToPyList<double>(tmp,sz);
{
if(!arr)
throw INTERP_KERNEL::Exception("wrap of MEDCouplingFieldDiscretization::normL2 : input array is null !");
- int sz(arr->getNumberOfComponents());
+ std::size_t sz(arr->getNumberOfComponents());
INTERP_KERNEL::AutoPtr<double> tmp=new double[sz];
self->normL2(mesh,arr,tmp);
return convertDblArrToPyList<double>(tmp,sz);
{
if(!arr)
throw INTERP_KERNEL::Exception("wrap of MEDCouplingFieldDiscretization::integral : input array is null !");
- int sz(arr->getNumberOfComponents());
+ std::size_t sz(arr->getNumberOfComponents());
INTERP_KERNEL::AutoPtr<double> tmp=new double[sz];
self->integral(mesh,arr,isWAbs,tmp);
return convertDblArrToPyList<double>(tmp,sz);
{
if(!arr)
throw INTERP_KERNEL::Exception("wrap of MEDCouplingFieldDiscretization::getValueOnPos : input array is null !");
- int sz(arr->getNumberOfComponents());
+ std::size_t sz(arr->getNumberOfComponents());
INTERP_KERNEL::AutoPtr<double> res=new double[sz];
self->getValueOnPos(arr,mesh,i,j,k,res);
return convertDblArrToPyList<double>(res,sz);
{
std::size_t sz(0);
const double *ret(MEDCouplingFieldDiscretizationGaussNE::GetWeightArrayFromGeometricType(geoType,sz));
- return convertDblArrToPyList<double>(ret,sz);
+ return convertDblArrToPyList<double>(ret,ToIdType(sz));
}
static PyObject *GetRefCoordsFromGeometricType(INTERP_KERNEL::NormalizedCellType geoType)
{
std::size_t sz(0);
const double *ret(MEDCouplingFieldDiscretizationGaussNE::GetRefCoordsFromGeometricType(geoType,sz));
- return convertDblArrToPyList<double>(ret,sz);
+ return convertDblArrToPyList<double>(ret,ToIdType(sz));
}
static PyObject *GetLocsFromGeometricType(INTERP_KERNEL::NormalizedCellType geoType)
{
std::size_t sz(0);
const double *ret(MEDCouplingFieldDiscretizationGaussNE::GetLocsFromGeometricType(geoType,sz));
- return convertDblArrToPyList<double>(ret,sz);
+ return convertDblArrToPyList<double>(ret,ToIdType(sz));
}
}
};
void checkNbOfComps(int nbOfCompo, const std::string& msg) const;
void checkNbOfTuplesAndComp(const DataArray& other, const std::string& msg) const;
void checkNbOfTuplesAndComp(int nbOfTuples, int nbOfCompo, const std::string& msg) const;
- void checkNbOfElems(std::size_t nbOfElems, const std::string& msg) const;
+ void checkNbOfElems(mcIdType nbOfElems, const std::string& msg) const;
static int GetNumberOfItemGivenBES(int begin, int end, int step, const std::string& msg);
static int GetNumberOfItemGivenBESRelative(int begin, int end, int step, const std::string& msg);
static int GetPosOfItemGivenBESRelativeNoThrow(int value, int begin, int end, int step);
Py_ssize_t strt=2,stp=2,step=2;
GetIndicesOfSliceExplicitely(slic,&strt,&stp,&step,"DataArray::GetSlice (wrap) : the input slice is invalid !");
mcIdType a,b;
- DataArray::GetSlice(strt,stp,step,sliceId,nbOfSlices,a,b);
+ DataArray::GetSlice(ToIdType(strt),ToIdType(stp),ToIdType(step),sliceId,nbOfSlices,a,b);
return PySlice_New(PyInt_FromLong(a),PyInt_FromLong(b),PyInt_FromLong(step));
}
Py_ssize_t strt=2,stp=2,step=2;
GetIndicesOfSlice(slic,self->getNumberOfTuples(),&strt,&stp,&step,"DataArray::getSlice (wrap) : the input slice is invalid !");
mcIdType a,b;
- DataArray::GetSlice(strt,stp,step,sliceId,nbOfSlices,a,b);
+ DataArray::GetSlice(ToIdType(strt),ToIdType(stp),ToIdType(step),sliceId,nbOfSlices,a,b);
return PySlice_New(PyInt_FromLong(a),PyInt_FromLong(b),PyInt_FromLong(step));
}
throw INTERP_KERNEL::Exception("DataArray::GetNumberOfItemGivenBES (wrap) : expecting a pyslice as second (first) parameter !");
Py_ssize_t strt=2,stp=2,step=2;
GetIndicesOfSliceExplicitely(slic,&strt,&stp,&step,"DataArray::GetNumberOfItemGivenBES (wrap) : the input slice is invalid !");
- return DataArray::GetNumberOfItemGivenBES(strt,stp,step,"");
+ return DataArray::GetNumberOfItemGivenBES(ToIdType(strt),ToIdType(stp),ToIdType(step),"");
}
static mcIdType GetNumberOfItemGivenBESRelative(PyObject *slic)
throw INTERP_KERNEL::Exception("DataArray::GetNumberOfItemGivenBESRelative (wrap) : expecting a pyslice as second (first) parameter !");
Py_ssize_t strt=2,stp=2,step=2;
GetIndicesOfSliceExplicitely(slic,&strt,&stp,&step,"DataArray::GetNumberOfItemGivenBESRelative (wrap) : the input slice is invalid !");
- return DataArray::GetNumberOfItemGivenBESRelative(strt,stp,step,"");
+ return DataArray::GetNumberOfItemGivenBESRelative(ToIdType(strt),ToIdType(stp),ToIdType(step),"");
}
static DataArray *Aggregate(PyObject *arrs)
throw INTERP_KERNEL::Exception("DataArray::getNumberOfItemGivenBES (wrap) : expecting a pyslice as second (first) parameter !");
Py_ssize_t strt=2,stp=2,step=2;
GetIndicesOfSlice(slic,self->getNumberOfTuples(),&strt,&stp,&step,"DataArray::getNumberOfItemGivenBES (wrap) : the input slice is invalid !");
- return DataArray::GetNumberOfItemGivenBES(strt,stp,step,"");
+ return DataArray::GetNumberOfItemGivenBES(ToIdType(strt),ToIdType(stp),ToIdType(step),"");
}
mcIdType getNumberOfItemGivenBESRelative(PyObject *slic)
throw INTERP_KERNEL::Exception("DataArray::getNumberOfItemGivenBESRelative (wrap) : expecting a pyslice as second (first) parameter !");
Py_ssize_t strt=2,stp=2,step=2;
GetIndicesOfSlice(slic,self->getNumberOfTuples(),&strt,&stp,&step,"DataArray::getNumberOfItemGivenBESRelative (wrap) : the input slice is invalid !");
- return DataArray::GetNumberOfItemGivenBESRelative(strt,stp,step,"");
+ return DataArray::GetNumberOfItemGivenBESRelative(ToIdType(strt),ToIdType(stp),ToIdType(step),"");
}
PyObject *__getstate__() const
const std::vector<std::string> &a1(self->getInfoOnComponents());
PyTuple_SetItem(ret,0,PyString_FromString(a0.c_str()));
//
- mcIdType sz(a1.size());
+ std::size_t sz(a1.size());
PyObject *ret1(PyList_New(sz));
- for(mcIdType i=0;i<sz;i++)
+ for(std::size_t i=0;i<sz;i++)
PyList_SetItem(ret1,i,PyString_FromString(a1[i].c_str()));
PyTuple_SetItem(ret,1,ret1);
//
static const char MSG[]="DataArrayDouble.__setstate__ : expected input is a tuple of size 2 with string as 1st arg and list of string as 2nd arg !";
if(!PyTuple_Check(inp))
throw INTERP_KERNEL::Exception("DataArrayDouble.__setstate__ : invalid input ! Invalid overwrite of __getstate__ ?");
- mcIdType sz(PyTuple_Size(inp));
+ std::size_t sz(PyTuple_Size(inp));
if(sz!=2)
throw INTERP_KERNEL::Exception("DataArrayDouble.__setstate__ : invalid tuple in input ! Should be of size 2 ! Invalid overwrite of __getstate__ ?");
PyObject *a0(PyTuple_GetItem(inp,0));
PyObject *getValuesAsTuple() const
{
const float *vals(self->begin());
- mcIdType nbOfComp(self->getNumberOfComponents()),nbOfTuples(self->getNumberOfTuples());
+ std::size_t nbOfComp(self->getNumberOfComponents());
+ mcIdType nbOfTuples(self->getNumberOfTuples());
return convertDblArrToPyListOfTuple<float>(vals,nbOfComp,nbOfTuples);
}
DataArrayIdType *findClosestTupleId(const DataArrayDouble *other) const;
DataArrayIdType *computeNbOfInteractionsWith(const DataArrayDouble *otherBBoxFrmt, double eps) const;
void setPartOfValues1(const DataArrayDouble *a, int bgTuples, int endTuples, int stepTuples, int bgComp, int endComp, int stepComp, bool strictCompoCompare=true);
- void setPartOfValuesSimple1(double a, int bgTuples, int endTuples, int stepTuples, int bgComp, int endComp, int stepComp);
+ void setPartOfValuesSimple1(double a, mcIdType bgTuples, mcIdType endTuples, mcIdType stepTuples, mcIdType bgComp, mcIdType endComp, mcIdType stepComp);
void setPartOfValuesAdv(const DataArrayDouble *a, const DataArrayIdType *tuplesSelec);
double getIJ(int tupleId, int compoId) const;
double front() const;
MCAuto<DataArrayIdType> findIdsGreaterThan(double val) const;
MCAuto<DataArrayIdType> findIdsLowerOrEqualTo(double val) const;
MCAuto<DataArrayIdType> findIdsLowerThan(double val) const;
- MCAuto<DataArrayIdType> convertToIntArr() const;
+ MCAuto<DataArrayInt32> convertToIntArr() const;
MCAuto<DataArrayDouble> selectPartDef(const PartDefinition* pd) const;
MCAuto<DataArrayDouble> cumSum() const;
MCAuto<DataArrayFloat> convertToFloatArr() const;
return self->doubleValue();
}
- int __len__() const
+ mcIdType __len__() const
{
if(self->isAllocated())
{
{
if(PyInt_Check(nbOfTuples))
{
- mcIdType nbOfTuples1=PyInt_AS_LONG(nbOfTuples);
+ mcIdType nbOfTuples1=ToIdType(PyInt_AS_LONG(nbOfTuples));
if(nbOfTuples1<0)
throw INTERP_KERNEL::Exception("DataArrayDouble::setValues : should be a positive set of allocated memory !");
if(nbOfComp && nbOfComp != Py_None)
{
if(PyInt_Check(nbOfComp))
{//DataArrayDouble.setValues([1.,3.,4.,5.],2,2)
- mcIdType nbOfCompo=PyInt_AS_LONG(nbOfComp);
+ mcIdType nbOfCompo=ToIdType(PyInt_AS_LONG(nbOfComp));
if(nbOfCompo<0)
throw INTERP_KERNEL::Exception("DataArrayDouble::setValues : should be a positive number of components !");
std::vector<double> tmp=fillArrayWithPyListDbl2(li,nbOfTuples1,nbOfCompo);
PyObject *getValuesAsTuple() const
{
const double *vals(self->begin());
- mcIdType nbOfComp(self->getNumberOfComponents()),nbOfTuples(self->getNumberOfTuples());
+ std::size_t nbOfComp(self->getNumberOfComponents());
+ mcIdType nbOfTuples(self->getNumberOfTuples());
return convertDblArrToPyListOfTuple<double>(vals,nbOfComp,nbOfTuples);
}
std::size_t nbOfCompo(self->getNumberOfComponents());
INTERP_KERNEL::AutoPtr<double> tmp(new double[2*nbOfCompo]);
self->getMinMaxPerComponent(tmp);
- PyObject *ret=convertDblArrToPyListOfTuple<double>(tmp,2,nbOfCompo);
+ PyObject *ret=convertDblArrToPyListOfTuple<double>(tmp,2,ToIdType(nbOfCompo));
return ret;
}
std::size_t nbOfCompo(self->getNumberOfComponents());
INTERP_KERNEL::AutoPtr<double> tmp(new double[nbOfCompo]);
self->normMaxPerComponent(tmp);
- return convertDblArrToPyList<double>(tmp,nbOfCompo);
+ return convertDblArrToPyList<double>(tmp,ToIdType(nbOfCompo));
}
PyObject *accumulate() const
std::size_t sz=self->getNumberOfComponents();
INTERP_KERNEL::AutoPtr<double> tmp=new double[sz];
self->accumulate(tmp);
- return convertDblArrToPyList<double>(tmp,sz);
+ return convertDblArrToPyList<double>(tmp,ToIdType(sz));
}
DataArrayDouble *accumulatePerChunck(PyObject *indexArr) const
DataArrayDoubleTuple *aa;
std::vector<double> bb;
mcIdType sw;
- mcIdType tupleId=-1,nbOfCompo=self->getNumberOfComponents();
- const double *pt=convertObjToPossibleCpp5_Safe(tuple,sw,val,a,aa,bb,"Python wrap of DataArrayDouble::distanceToTuple",1,nbOfCompo,true);
+ mcIdType tupleId=-1;
+ std::size_t nbOfCompo=self->getNumberOfComponents();
+ const double *pt=convertObjToPossibleCpp5_Safe(tuple,sw,val,a,aa,bb,"Python wrap of DataArrayDouble::distanceToTuple",1,(int)nbOfCompo,true);
//
double ret0=self->distanceToTuple(pt,pt+nbOfCompo,tupleId);
PyObject *ret=PyTuple_New(2);
std::size_t sz=self->getNumberOfComponents();
INTERP_KERNEL::AutoPtr<double> tmp=new double[sz];
self->getTuple(tupleId,tmp);
- return convertDblArrToPyList<double>(tmp,sz);
+ return convertDblArrToPyList<double>(tmp,ToIdType(sz));
}
static DataArrayDouble *Aggregate(PyObject *li)
DataArrayDoubleTuple *aa;
std::vector<double> bb;
mcIdType sw;
- mcIdType nbComp=self->getNumberOfComponents(),nbTuples=-1;
+ std::size_t nbComp=self->getNumberOfComponents();
+ mcIdType nbTuples=-1;
const char msg[]="Python wrap of DataArrayDouble::computeTupleIdsNearTuples : ";
- const double *pos=convertObjToPossibleCpp5_Safe2(pt,sw,val,a,aa,bb,msg,nbComp,true,nbTuples);
+ const double *pos=convertObjToPossibleCpp5_Safe2(pt,sw,val,a,aa,bb,msg,(int)nbComp,true,nbTuples);
MCAuto<DataArrayDouble> inpu=DataArrayDouble::New(); inpu->useArray(pos,false,DeallocType::CPP_DEALLOC,nbTuples,nbComp);
DataArrayIdType *c=0,*cI=0;
self->computeTupleIdsNearTuples(inpu,eps,c,cI);
std::pair<mcIdType, std::pair<mcIdType,mcIdType> > slic;
MEDCoupling::DataArrayIdType *daIntTyypp=0;
const double *pt=self->getConstPointer();
- mcIdType nbc=self->getNumberOfCompo();
+ mcIdType nbc=ToIdType(self->getNumberOfCompo());
convertIntStarOrSliceLikePyObjToCppWithNegIntInterp(obj,nbc,sw,singleVal,multiVal,slic,daIntTyypp);
switch(sw)
{
double singleValV;
std::vector<double> multiValV;
MEDCoupling::DataArrayDoubleTuple *daIntTyyppV=0;
- mcIdType nbc=self->getNumberOfCompo();
+ mcIdType nbc=ToIdType(self->getNumberOfCompo());
convertDoubleStarLikePyObjToCpp(value,sw1,singleValV,multiValV,daIntTyyppV);
mcIdType singleVal;
std::vector<mcIdType> multiVal;
void fillWithValue(char val);
std::string repr() const;
std::string reprZip() const;
- DataArrayIdType *convertToIntArr() const;
+ DataArrayInt *convertToIntArr() const;
DataArrayChar *renumber(const mcIdType *old2New) const;
DataArrayChar *renumberR(const mcIdType *new2Old) const;
DataArrayChar *renumberAndReduce(const mcIdType *old2NewBg, mcIdType newNbOfTuple) const;
{
if(PyInt_Check(nbOfTuples))
{
- mcIdType nbOfTuples1=PyInt_AS_LONG(nbOfTuples);
+ mcIdType nbOfTuples1=ToIdType(PyInt_AS_LONG(nbOfTuples));
if(nbOfTuples1<0)
throw INTERP_KERNEL::Exception("DataArrayByte::New : should be a positive set of allocated memory !");
if(nbOfComp)
{
if(PyInt_Check(nbOfComp))
{//DataArrayByte.New([1,3,4,5],2,2)
- mcIdType nbOfCompo=PyInt_AS_LONG(nbOfComp);
+ mcIdType nbOfCompo=ToIdType(PyInt_AS_LONG(nbOfComp));
if(nbOfCompo<0)
throw INTERP_KERNEL::Exception("DataArrayByte::New : should be a positive number of components !");
MCAuto<DataArrayByte> ret=DataArrayByte::New();
}
else if(PyInt_Check(elt0))
{
- mcIdType nbOfTuples1=PyInt_AS_LONG(elt0);
+ mcIdType nbOfTuples1=ToIdType(PyInt_AS_LONG(elt0));
if(nbOfTuples1<0)
throw INTERP_KERNEL::Exception("DataArrayByte::New : should be a positive set of allocated memory !");
if(nbOfTuples)
{
if(PyInt_Check(nbOfTuples))
{//DataArrayByte.New(5,2)
- mcIdType nbOfCompo=PyInt_AS_LONG(nbOfTuples);
+ mcIdType nbOfCompo=ToIdType(PyInt_AS_LONG(nbOfTuples));
if(nbOfCompo<0)
throw INTERP_KERNEL::Exception("DataArrayByte::New : should be a positive number of components !");
MCAuto<DataArrayByte> ret=DataArrayByte::New();
PyObject *toStrList() const
{
const char *vals=self->getConstPointer();
- mcIdType nbOfComp=self->getNumberOfComponents();
+ std::size_t nbOfComp=self->getNumberOfComponents();
mcIdType nbOfTuples=self->getNumberOfTuples();
- return convertCharArrToPyListOfTuple(vals,nbOfComp,nbOfTuples);
+ return convertCharArrToPyListOfTuple(vals,(int)nbOfComp,nbOfTuples);
}
bool presenceOfTuple(PyObject *tupl) const
PyObject *getTuple(mcIdType tupleId)
{
- mcIdType sz=self->getNumberOfComponents();
+ std::size_t sz=self->getNumberOfComponents();
INTERP_KERNEL::AutoPtr<char> tmp=new char[sz];
self->getTuple(tupleId,tmp);
PyObject *ret=PyTuple_New(sz);
- for(mcIdType i=0;i<sz;i++) PyTuple_SetItem(ret,i,PyInt_FromLong((mcIdType)tmp[i]));
+ for(std::size_t i=0;i<sz;i++) PyTuple_SetItem(ret,i,PyInt_FromLong((mcIdType)tmp[i]));
return ret;
}
mcIdType index(PyObject *obj) const
{
- mcIdType nbOfCompo=self->getNumberOfComponents();
+ std::size_t nbOfCompo=self->getNumberOfComponents();
switch(nbOfCompo)
{
case 1:
{
if(PyInt_Check(obj))
{
- mcIdType val=(mcIdType)PyInt_AS_LONG(obj);
+ char val=(char)PyInt_AS_LONG(obj);
return self->findIdFirstEqual(val);
}
else
bool __contains__(PyObject *obj) const
{
- mcIdType nbOfCompo=self->getNumberOfComponents();
+ std::size_t nbOfCompo=self->getNumberOfComponents();
switch(nbOfCompo)
{
case 0:
{
if(PyInt_Check(obj))
{
- mcIdType val=(mcIdType)PyInt_AS_LONG(obj);
+ char val=(char)PyInt_AS_LONG(obj);
return self->presenceOfValue(val);
}
else
{
self->checkAllocated();
const char msg[]="Unexpected situation in __setitem__ !";
- mcIdType nbOfTuples(self->getNumberOfTuples()),nbOfComponents(self->getNumberOfComponents());
+ mcIdType nbOfTuples(self->getNumberOfTuples());
+ int nbOfComponents((int)self->getNumberOfComponents());
mcIdType sw1,sw2;
- mcIdType i1;
- std::vector<mcIdType> v1;
+ int int1;
+ std::vector<int> v1;
DataArrayIdType *d1=0;
- DataArrayIdTypeTuple *dd1=0;
- convertIntStarLikePyObjToCpp(value,sw1,i1,v1,d1,dd1);
+ DataArrayIntTuple *dd1=0;
+ convertIntStarLikePyObjToCpp(value,sw1,int1,v1,d1,dd1);
mcIdType it1,ic1;
std::vector<mcIdType> vt1,vc1;
std::pair<mcIdType, std::pair<mcIdType,mcIdType> > pt1,pc1;
DataArrayIdType *dt1=0,*dc1=0;
convertObjToPossibleCpp3(obj,nbOfTuples,nbOfComponents,sw2,it1,ic1,vt1,vc1,pt1,pc1,dt1,dc1);
MCAuto<DataArrayIdType> tmp;
+ char i1 = (char)int1;
switch(sw2)
{
case 1:
{
if(PyInt_Check(nbOfTuples))
{
- mcIdType nbOfTuples1=PyInt_AS_LONG(nbOfTuples);
+ mcIdType nbOfTuples1=ToIdType(PyInt_AS_LONG(nbOfTuples));
if(nbOfTuples1<0)
throw INTERP_KERNEL::Exception("DataArrayAsciiChar::New : should be a positive set of allocated memory !");
if(nbOfComp)
{
if(PyInt_Check(nbOfComp))
{//DataArrayAsciiChar.New([1,3,4,5],2,2)
- mcIdType nbOfCompo=PyInt_AS_LONG(nbOfComp);
+ mcIdType nbOfCompo=ToIdType(PyInt_AS_LONG(nbOfComp));
if(nbOfCompo<0)
throw INTERP_KERNEL::Exception("DataArrayAsciiChar::New : should be a positive number of components !");
MCAuto<DataArrayAsciiChar> ret=DataArrayAsciiChar::New();
}
else if(PyInt_Check(elt0))
{
- mcIdType nbOfTuples1=PyInt_AS_LONG(elt0);
+ mcIdType nbOfTuples1=ToIdType(PyInt_AS_LONG(elt0));
if(nbOfTuples1<0)
throw INTERP_KERNEL::Exception("DataArrayAsciiChar::New : should be a positive set of allocated memory !");
if(nbOfTuples)
{
if(PyInt_Check(nbOfTuples))
{//DataArrayAsciiChar.New(5,2)
- mcIdType nbOfCompo=PyInt_AS_LONG(nbOfTuples);
+ mcIdType nbOfCompo=ToIdType(PyInt_AS_LONG(nbOfTuples));
if(nbOfCompo<0)
throw INTERP_KERNEL::Exception("DataArrayAsciiChar::New : should be a positive number of components !");
MCAuto<DataArrayAsciiChar> ret=DataArrayAsciiChar::New();
PyObject *toStrList() const
{
const char *vals=self->getConstPointer();
- mcIdType nbOfComp=self->getNumberOfComponents();
+ std::size_t nbOfComp=self->getNumberOfComponents();
mcIdType nbOfTuples=self->getNumberOfTuples();
- return convertCharArrToPyListOfTuple(vals,nbOfComp,nbOfTuples);
+ return convertCharArrToPyListOfTuple(vals,(int)nbOfComp,nbOfTuples);
}
bool presenceOfTuple(PyObject *tupl) const
PyObject *getTuple(mcIdType tupleId) const
{
- mcIdType sz=self->getNumberOfComponents();
+ std::size_t sz=self->getNumberOfComponents();
INTERP_KERNEL::AutoPtr<char> tmp=new char[sz+1]; tmp[sz]='\0';
self->getTuple(tupleId,tmp);
return PyString_FromString(tmp);
mcIdType index(PyObject *obj) const
{
- mcIdType nbOfCompo=self->getNumberOfComponents();
+ std::size_t nbOfCompo=self->getNumberOfComponents();
switch(nbOfCompo)
{
case 1:
bool __contains__(PyObject *obj) const
{
- mcIdType nbOfCompo=self->getNumberOfComponents();
+ std::size_t nbOfCompo=self->getNumberOfComponents();
switch(nbOfCompo)
{
case 0:
std::vector<mcIdType> stdvecTyyppArr;
std::pair<mcIdType, std::pair<mcIdType,mcIdType> > sTyyppArr;
MEDCoupling::DataArrayIdType *daIntTyypp=0;
- mcIdType nbOfCompo=self->getNumberOfComponents();
+ mcIdType nbOfCompo=ToIdType(self->getNumberOfComponents());
mcIdType nbOfTuples=self->getNumberOfTuples();
convertIntStarOrSliceLikePyObjToCppWithNegIntInterp(obj,nbOfTuples,sw1,iTypppArr,stdvecTyyppArr,sTyyppArr,daIntTyypp);
mcIdType sw2;
a=a.cumsum(dtype=int32)
a=array(a,dtype=int64) ; a=array(a,dtype=int32)
self.assertEqual(getrefcount(a),2)
- d=DataArrayInt(a)
+ d=DataArrayInt32(a)
d[:]=2
#
- e=DataArrayInt(sz) ; e.fillWithValue(2)
+ e=DataArrayInt32(sz) ; e.fillWithValue(2)
self.assertTrue(d.isEqual(e))
#
a[:]=4 ; e.fillWithValue(4)
self.assertEqual(getrefcount(a),3)
self.assertEqual(getrefcount(b),2)
b[:]=5
- d=DataArrayInt(b)
+ d=DataArrayInt32(b)
#
- e=DataArrayInt(sz*2) ; e.fillWithValue(5)
+ e=DataArrayInt32(sz*2) ; e.fillWithValue(5)
self.assertTrue(d.isEqual(e))
pass
c=a.reshape(2,sz)
b[:]=6
b[7:17]=7
- d=DataArrayInt(b)
- self.assertTrue(d.isEqual(DataArrayInt([6,6,6,6,6,6,6,7,7,7,7,7,7,7,7,7,7,6,6,6])))
+ d=DataArrayInt32(b)
+ self.assertTrue(d.isEqual(DataArrayInt32([6,6,6,6,6,6,6,7,7,7,7,7,7,7,7,7,7,6,6,6])))
#
a=zeros((10,2),dtype=int32)
b=a.T
c=b.view()
a.shape=20
a[3:]=10.
- d=DataArrayInt(a)
- self.assertTrue(d.isEqual(DataArrayInt([0,0,0,10,10,10,10,10,10,10,10,10,10,10,10,10,10,10,10,10])))
+ d=DataArrayInt32(a)
+ self.assertTrue(d.isEqual(DataArrayInt32([0,0,0,10,10,10,10,10,10,10,10,10,10,10,10,10,10,10,10,10])))
pass
@unittest.skipUnless(MEDCouplingHasNumPyBindings(),"requires numpy")
def test5(self):
a=arange(20,dtype=int32)
self.assertEqual(weakref.getweakrefcount(a),0)
- d=DataArrayInt(a)
+ d=DataArrayInt32(a)
self.assertEqual(weakref.getweakrefcount(a),1)
self.assertTrue(not a.flags["OWNDATA"])
self.assertTrue(d.isIota(20))
gc.collect()
self.assertTrue(a.flags["OWNDATA"])
a[:]=4 # a can be used has usual
- self.assertTrue(DataArrayInt(a).isUniform(4))
+ self.assertTrue(DataArrayInt32(a).isUniform(4))
pass
@unittest.skipUnless(MEDCouplingHasNumPyBindings(),"requires numpy")
def test6(self):
a=arange(20,dtype=int32)
- d=DataArrayInt(a) # d owns data of a
- e=DataArrayInt(a) # a not owned -> e only an access to chunk of a
+ d=DataArrayInt32(a) # d owns data of a
+ e=DataArrayInt32(a) # a not owned -> e only an access to chunk of a
self.assertTrue(d.isIota(d.getNumberOfTuples()))
self.assertTrue(e.isIota(e.getNumberOfTuples()))
a[:]=6
a=array(0,dtype=int32) ; a.resize(10,2)
b=a.reshape(20)
c=a.reshape(2,10)
- d=DataArrayInt(b) # d owns data of a
- e=DataArrayInt(b) # a not owned -> e only an access to chunk of a
- f=DataArrayInt(b) # a not owned -> e only an access to chunk of a
+ d=DataArrayInt32(b) # d owns data of a
+ e=DataArrayInt32(b) # a not owned -> e only an access to chunk of a
+ f=DataArrayInt32(b) # a not owned -> e only an access to chunk of a
del d # d removed -> a ownes again data
##@@ Ensure a pass of the garbage collector so that the de-allocator of d is called
import gc
def test8(self):
a=arange(20,dtype=int32)
self.assertTrue(a.flags["OWNDATA"])
- d=DataArrayInt(a) # d owns data of a
+ d=DataArrayInt32(a) # d owns data of a
self.assertTrue(not a.flags["OWNDATA"])
d.pushBackSilent(20)# d pushBack so release of chunk of data -> a becomes owner of its data again
self.assertTrue(a.flags["OWNDATA"])
- self.assertTrue(d.isEqual(DataArrayInt([0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20])))
+ self.assertTrue(d.isEqual(DataArrayInt32([0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20])))
self.assertEqual(a.tolist(),[0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19])
pass
a.resize(sz//2,2)
a[:]=4
self.assertEqual(getrefcount(a),2)
- d=DataArrayInt(a)
+ d=DataArrayInt32(a)
self.assertEqual(10,d.getNumberOfTuples())
self.assertEqual(2,d.getNumberOfComponents())
self.assertEqual(sz,d.getNbOfElems())
- self.assertTrue(d.isEqual(DataArrayInt([(4,4),(4,4),(4,4),(4,4),(4,4),(4,4),(4,4),(4,4),(4,4),(4,4)])))
+ self.assertTrue(d.isEqual(DataArrayInt32([(4,4),(4,4),(4,4),(4,4),(4,4),(4,4),(4,4),(4,4),(4,4),(4,4)])))
a[:]=7
- self.assertTrue(d.isEqual(DataArrayInt([(7,7),(7,7),(7,7),(7,7),(7,7),(7,7),(7,7),(7,7),(7,7),(7,7)])))
+ self.assertTrue(d.isEqual(DataArrayInt32([(7,7),(7,7),(7,7),(7,7),(7,7),(7,7),(7,7),(7,7),(7,7),(7,7)])))
#
b=a.reshape((2,5,2))
self.assertRaises(InterpKernelException,DataArrayInt.New,b) # b has not dimension in [0,1] !
#tests that only DataArray*(npArray) constructor is available
a=array(0,dtype=int32)
a.resize(20)
- DataArrayInt(a)
+ DataArrayInt32(a)
self.assertRaises(InterpKernelException,DataArrayInt.New,a,20)
self.assertRaises(InterpKernelException,DataArrayInt.New,a,20,1)
a=array(0,dtype=float64)
@unittest.skipUnless(MEDCouplingHasNumPyBindings(),"requires numpy")
def test25(self):
a=arange(10,dtype=int32)
- b=DataArrayInt(a)
- c=DataArrayInt(a)
- d=DataArrayInt(a)
+ b=DataArrayInt32(a)
+ c=DataArrayInt32(a)
+ d=DataArrayInt32(a)
self.assertTrue(b.isIota(10))
self.assertTrue(c.isIota(10))
self.assertTrue(d.isIota(10))
self.assertTrue(c.isIota(11))
#
a=arange(10,dtype=int32)
- b=DataArrayInt(a)
- c=DataArrayInt(a)
+ b=DataArrayInt32(a)
+ c=DataArrayInt32(a)
self.assertTrue(b.isIota(10))
self.assertTrue(c.isIota(10))
b.pushBackSilent(10) # c and a,b are dissociated
self.assertEqual(a.ndim,2)
self.assertEqual(a.size,15)
self.assertEqual(a.shape,(5,3))
- self.assertEqual(a.strides,(12,4))
- self.assertEqual(a.nbytes,60)
- self.assertEqual(a.itemsize,4)
+ self.assertEqual(a.strides,(3*MEDCouplingSizeOfIDs()//8,MEDCouplingSizeOfIDs()//8))
+ self.assertEqual(a.nbytes,15*MEDCouplingSizeOfIDs()//8)
+ self.assertEqual(a.itemsize,MEDCouplingSizeOfIDs()//8)
self.assertEqual(a.tolist(),[[0,1,2],[3,4,5],[6,7,8],[9,10,11],[12,13,14]])
#
d2=d.convertToDblArr()
f.setName("aname")
a=f.getArray()
b=a[:] ; b.iota(7000)
- f.setArray(DataArrayInt.Meld(a,b))
+ f.setArray(DataArrayInt32.Meld(a,b))
f.getArray().setInfoOnComponents(["u1","vv2"])
f.checkConsistencyLight();
#
PyObject *indptr(PyObject_GetAttrString(m,"indptr"));
PyObject *indices(PyObject_GetAttrString(m,"indices"));
PyObject *data(PyObject_GetAttrString(m,"data"));
- MCAuto<DataArrayIdType> indptrPtr, indicesPtr;
-#if defined(MEDCOUPLING_USE_64BIT_IDS)
- indptrPtr = MEDCoupling_DataArrayInt64_New__SWIG_1(indptr,NULL,NULL);
- indicesPtr = MEDCoupling_DataArrayInt64_New__SWIG_1(indices,NULL,NULL);
-#else
+ MCAuto<DataArrayInt32> indptrPtr, indicesPtr;
+ // csr_matrix.indptr and csr_matrix.indices are always dtype==int32
+// #if defined(MEDCOUPLING_USE_64BIT_IDS)
+// indptrPtr = MEDCoupling_DataArrayInt64_New__SWIG_1(indptr,NULL,NULL);
+// indicesPtr = MEDCoupling_DataArrayInt64_New__SWIG_1(indices,NULL,NULL);
+// #else
indptrPtr = MEDCoupling_DataArrayInt32_New__SWIG_1(indptr,NULL,NULL);
indicesPtr = MEDCoupling_DataArrayInt32_New__SWIG_1(indices,NULL,NULL);
-#endif
+//#endif
MCAuto<DataArrayDouble> dataPtr(MEDCoupling_DataArrayDouble_New__SWIG_1(data,NULL,NULL));
convertCSR_MCDataToVectMapIntDouble(indptrPtr,indicesPtr,dataPtr,mCpp);
Py_XDECREF(data); Py_XDECREF(indptr); Py_XDECREF(indices);
vals*=1e-5
eps0=DataArrayDouble(m0.data)-vals ; eps0.abs()
self.assertTrue(eps0.findIdsInRange(1e-17,1e300).empty())
- self.assertTrue(DataArrayInt(m0.indices).isEqual(DataArrayInt([0,1,3,1,4,5,4,6,7,6,8,9,8,10,11,10,12,13,12,14,15,14,16,17,16,18,19,18,20,21,20,22,23,22,24,25,24,26,27,0,2,3,1,3,5,4,5,7,6,7,9,8,9,11,10,11,13,12,13,15,14,15,17,16,17,19,18,19,21,20,21,23,22,23,25,24,25,27,0,2,3,1,3,5,4,5,7,6,7,9,8,9,11,10,11,13,12,13,15,14,15,17,16,17,19,18,19,21,20,21,23,22,23,25,24,25,27,0,2,3,1,3,5,4,5,7,6,7,9,8,9,11,10,11,13,12,13,15,14,15,17,16,17,19,18,19,21,20,21,23,22,23,25,24,25,27,0,2,3,1,3,5,4,5,7,6,7,9,8,9,11,10,11,13,12,13,15,14,15,17,16,17,19,18,19,21,20,21,23,22,23,25,24,25,27,0,1,3,1,4,5,4,6,7,6,8,9,8,10,11,10,12,13,12,14,15,14,16,17,16,18,19,18,20,21,20,22,23,22,24,25,24,26,27,0,1,3,1,4,5,4,6,7,6,8,9,8,10,11,10,12,13,12,14,15,14,16,17,16,18,19,18,20,21,20,22,23,22,24,25,24,26,27,0,1,3,1,4,5,4,6,7,6,8,9,8,10,11,10,12,13,12,14,15,14,16,17,16,18,19,18,20,21,20,22,23,22,24,25,24,26,27])))
- self.assertTrue(DataArrayInt(m0.indptr).isEqual(DataArrayInt([0,3,6,9,12,15,18,21,24,27,30,33,36,39,42,45,48,51,54,57,60,63,66,69,72,75,78,81,84,87,90,93,96,99,102,105,108,111,114,117,120,123,126,129,132,135,138,141,144,147,150,153,156,159,162,165,168,171,174,177,180,183,186,189,192,195,198,201,204,207,210,213,216,219,222,225,228,231,234,237,240,243,246,249,252,255,258,261,264,267,270,273,276,279,282,285,288,291,294,297,300,303,306,309,312])))
+ self.assertTrue(DataArrayInt32(m0.indices).isEqual(DataArrayInt32([0,1,3,1,4,5,4,6,7,6,8,9,8,10,11,10,12,13,12,14,15,14,16,17,16,18,19,18,20,21,20,22,23,22,24,25,24,26,27,0,2,3,1,3,5,4,5,7,6,7,9,8,9,11,10,11,13,12,13,15,14,15,17,16,17,19,18,19,21,20,21,23,22,23,25,24,25,27,0,2,3,1,3,5,4,5,7,6,7,9,8,9,11,10,11,13,12,13,15,14,15,17,16,17,19,18,19,21,20,21,23,22,23,25,24,25,27,0,2,3,1,3,5,4,5,7,6,7,9,8,9,11,10,11,13,12,13,15,14,15,17,16,17,19,18,19,21,20,21,23,22,23,25,24,25,27,0,2,3,1,3,5,4,5,7,6,7,9,8,9,11,10,11,13,12,13,15,14,15,17,16,17,19,18,19,21,20,21,23,22,23,25,24,25,27,0,1,3,1,4,5,4,6,7,6,8,9,8,10,11,10,12,13,12,14,15,14,16,17,16,18,19,18,20,21,20,22,23,22,24,25,24,26,27,0,1,3,1,4,5,4,6,7,6,8,9,8,10,11,10,12,13,12,14,15,14,16,17,16,18,19,18,20,21,20,22,23,22,24,25,24,26,27,0,1,3,1,4,5,4,6,7,6,8,9,8,10,11,10,12,13,12,14,15,14,16,17,16,18,19,18,20,21,20,22,23,22,24,25,24,26,27])))
+ self.assertTrue(DataArrayInt32(m0.indptr).isEqual(DataArrayInt32([0,3,6,9,12,15,18,21,24,27,30,33,36,39,42,45,48,51,54,57,60,63,66,69,72,75,78,81,84,87,90,93,96,99,102,105,108,111,114,117,120,123,126,129,132,135,138,141,144,147,150,153,156,159,162,165,168,171,174,177,180,183,186,189,192,195,198,201,204,207,210,213,216,219,222,225,228,231,234,237,240,243,246,249,252,255,258,261,264,267,270,273,276,279,282,285,288,291,294,297,300,303,306,309,312])))
#
rem2=MEDCouplingRemapper() ; rem2.setIntersectionType(Barycentric)
rem2.prepare(b,a,"P0P1")
rem.setMinDotBtwPlane3DSurfIntersect(0.99)# this line is important it is to tell to remapper to select only cells with very close orientation
rem.prepare(skinAndNonConformCells,skinAndNonConformCells,"P0P0")
mat=rem.getCrudeCSRMatrix()
- indptr=DataArrayInt(mat.indptr)
+ indptr=DataArrayInt32(mat.indptr) #not depend on MEDCouplingUse64BitIDs()
indptr2=indptr.deltaShiftIndex()
cellIdsOfNonConformCells=indptr2.findIdsNotEqual(1)
cellIdsOfSkin=indptr2.findIdsEqual(1)
if(!self->getArray())
throw INTERP_KERNEL::Exception("MEDCouplingFieldDouble::__getitem__ : no array set on field to deduce number of components !");
try
- { convertIntStarOrSliceLikePyObjToCpp(elt1,self->getArray()->getNumberOfComponents(),sw,singleVal,multiVal,slic,daIntTyypp); }
+ { convertIntStarOrSliceLikePyObjToCpp(elt1,ToIdType(self->getArray()->getNumberOfComponents()),sw,singleVal,multiVal,slic,daIntTyypp); }
catch(INTERP_KERNEL::Exception& e)
{ std::ostringstream oss; oss << "MEDCouplingFieldDouble::__getitem__ : invalid type in 2nd parameter (compo) !" << e.what(); throw INTERP_KERNEL::Exception(oss.str().c_str()); }
typename MEDCoupling::MCAuto< typename MEDCoupling::Traits<T>::FieldType > ret0(fieldT_buildSubPart<T>(self,elt0));
PyObject *ret(PyTuple_New(3));
PyTuple_SetItem(ret,0,convertDblArrToPyList2(a0));
PyTuple_SetItem(ret,1,convertIntArrToPyList2(a1));
- mcIdType sz(a2.size());
+ std::size_t sz(a2.size());
PyObject *ret2(PyList_New(sz));
{
- for(mcIdType i=0;i<sz;i++)
+ for(std::size_t i=0;i<sz;i++)
PyList_SetItem(ret2,i,PyString_FromString(a2[i].c_str()));
}
PyTuple_SetItem(ret,2,ret2);
static const char MSG[]="MEDCouplingFieldDouble.__setstate__ : expected input is a tuple of size 3 !";
if(!PyTuple_Check(inp))
throw INTERP_KERNEL::Exception(MSG);
- mcIdType sz(PyTuple_Size(inp));
+ std::size_t sz(PyTuple_Size(inp));
if(sz!=3)
throw INTERP_KERNEL::Exception(MSG);
// mesh
throw INTERP_KERNEL::Exception("MEDCouplingMesh::getCellsContainingPoints : Not null DataArrayDouble instance expected !");
da2->checkAllocated();
mcIdType size=da2->getNumberOfTuples();
- mcIdType nbOfCompo=da2->getNumberOfComponents();
+ mcIdType nbOfCompo=ToIdType(da2->getNumberOfComponents());
if(nbOfCompo!=spaceDim)
{
throw INTERP_KERNEL::Exception("MEDCouplingMesh::getCellsContainingPoints : Invalid DataArrayDouble nb of components ! Expected same as self.getSpaceDimension() !");
# NumPy is an optional pre-requisite!
assert(MEDCoupling.MEDCouplingHasNumPyBindings())
a=numpy.arange(20,dtype=numpy.int32)
-d=DataArrayInt(a) # d owns data of a
-e=DataArrayInt(a) # a not owned -> e only an access to chunk of a
+d=DataArrayInt32(a) # d owns data of a
+e=DataArrayInt32(a) # a not owned -> e only an access to chunk of a
a1=d.toNumPyArray()
#! [UG_DataArrayNumpy_0]