return std::accumulate(tmp,tmp+spaceDim,0);
}
-void MEDCouplingCMesh::getPosFromId(int nodeId, int spaceDim, const int *split, int *res)
+void MEDCouplingCMesh::GetPosFromId(int nodeId, int spaceDim, const int *split, int *res)
{
int work=nodeId;
for(int i=spaceDim-1;i>=0;i--)
getSplitNodeValues(tmp);
const DataArrayDouble *tabs[3]={getCoordsAt(0),getCoordsAt(1),getCoordsAt(2)};
int tmp2[3];
- getPosFromId(nodeId,spaceDim,tmp,tmp2);
+ GetPosFromId(nodeId,spaceDim,tmp,tmp2);
for(int j=0;j<spaceDim;j++)
if(tabs[j])
coo.push_back(tabs[j]->getConstPointer()[tmp2[j]]);
for(int icell=0;icell<nbelem;icell++)
{
int tmp2[3];
- getPosFromId(icell,dim,tmp,tmp2);
+ GetPosFromId(icell,dim,tmp,tmp2);
area_vol[icell]=1.;
for(int i=0;i<dim;i++)
area_vol[icell]*=thisArr[i][tmp2[i]+1]-thisArr[i][tmp2[i]];
int tmp2[3];
for(int i=0;i<nbNodes;i++)
{
- getPosFromId(i,spaceDim,tmp,tmp2);
+ GetPosFromId(i,spaceDim,tmp,tmp2);
for(int j=0;j<spaceDim;j++)
pt[i*spaceDim+j]=tabsPtr[j][tmp2[j]];
}
int tmp2[3];
for(int i=0;i<nbCells;i++)
{
- getPosFromId(i,spaceDim,tmp,tmp2);
+ GetPosFromId(i,spaceDim,tmp,tmp2);
for(int j=0;j<spaceDim;j++)
pt[i*spaceDim+j]=tabsPtr[j][tmp2[j]];
}
int getMeshDimension() const;
int getCellIdFromPos(int i, int j, int k) const;
int getNodeIdFromPos(int i, int j, int k) const;
- static void getPosFromId(int nodeId, int spaceDim, const int *split, int *res);
+ static void GetPosFromId(int nodeId, int spaceDim, const int *split, int *res);
INTERP_KERNEL::NormalizedCellType getTypeOfCell(int cellId) const;
int getNumberOfCellsWithType(INTERP_KERNEL::NormalizedCellType type) const;
void getNodeIdsOfCell(int cellId, std::vector<int>& conn) const;
MEDCouplingUMesh *MEDCouplingExtrudedMesh::build3DUnstructuredMesh() const
{
- MEDCouplingUMesh *ret=_mesh2D->buildExtrudedMeshFromThis(_mesh1D,0);
+ MEDCouplingUMesh *ret=_mesh2D->buildExtrudedMesh(_mesh1D,0);
const int *renum=_mesh3D_ids->getConstPointer();
ret->renumberCells(renum,false);
ret->setName(getName());
std::transform(zoneToUpdate,zoneToUpdate+3,zoneToUpdate,std::bind2nd(std::multiplies<double>(),(double)(1./nodalConnec.size())));
}
-int MEDCouplingExtrudedMesh::findCorrespCellByNodalConn(const std::vector<int>& nodalConnec, const int *revNodalPtr, const int *revNodalIndxPtr) throw(INTERP_KERNEL::Exception)
+int MEDCouplingExtrudedMesh::FindCorrespCellByNodalConn(const std::vector<int>& nodalConnec, const int *revNodalPtr, const int *revNodalIndxPtr) throw(INTERP_KERNEL::Exception)
{
std::vector<int>::const_iterator iter=nodalConnec.begin();
std::set<int> s1(revNodalPtr+revNodalIndxPtr[*iter],revNodalPtr+revNodalIndxPtr[*iter+1]);
* @param v is the output normalized vector of the common direction of 'm1' and 'm2'
* @throw in case that m1 and m2 are not compatible each other.
*/
-void MEDCouplingExtrudedMesh::project1DMeshes(const MEDCouplingUMesh *m1, const MEDCouplingUMesh *m2, double eps,
+void MEDCouplingExtrudedMesh::Project1DMeshes(const MEDCouplingUMesh *m1, const MEDCouplingUMesh *m2, double eps,
MEDCouplingUMesh *&m1r, MEDCouplingUMesh *&m2r, double *v) throw(INTERP_KERNEL::Exception)
{
if(m1->getSpaceDimension()!=3 || m1->getSpaceDimension()!=3)
- throw INTERP_KERNEL::Exception("Input meshes are expected to have a spaceDim==3 for projec1D !");
+ throw INTERP_KERNEL::Exception("Input meshes are expected to have a spaceDim==3 for Projec1D !");
m1r=m1->clone(true);
m2r=m2->clone(true);
m1r->changeSpaceDimension(1);
std::vector<int> nodalConnec(nodal2D+nodal2DIndx[i]+1,nodal2D+nodal2DIndx[i+1]);
try
{
- idInSubMesh=findCorrespCellByNodalConn(nodalConnec,revNodal2DPtr,revNodalIndx2DPtr);
+ idInSubMesh=FindCorrespCellByNodalConn(nodalConnec,revNodal2DPtr,revNodalIndx2DPtr);
}
catch(INTERP_KERNEL::Exception& e)
{
MEDCouplingFieldDouble *getMeasureFieldOnNode(bool) const;
MEDCouplingFieldDouble *buildOrthogonalField() const;
int getCellContainingPoint(const double *pos, double eps) const;
- static int findCorrespCellByNodalConn(const std::vector<int>& nodalConnec,
+ static int FindCorrespCellByNodalConn(const std::vector<int>& nodalConnec,
const int *revNodalPtr, const int *revNodalIndxPtr) throw(INTERP_KERNEL::Exception);
- static void project1DMeshes(const MEDCouplingUMesh *m1, const MEDCouplingUMesh *m2, double eps,
+ static void Project1DMeshes(const MEDCouplingUMesh *m1, const MEDCouplingUMesh *m2, double eps,
MEDCouplingUMesh *&m1r, MEDCouplingUMesh *&m2r, double *v) throw(INTERP_KERNEL::Exception);
void rotate(const double *center, const double *vector, double angle);
void translate(const double *vector);
{
const int *array=old2NewBg;
if(check)
- array=DataArrayInt::checkAndPreparePermutation(old2NewBg,old2NewBg+mesh->getNumberOfCells());
+ array=DataArrayInt::CheckAndPreparePermutation(old2NewBg,old2NewBg+mesh->getNumberOfCells());
for(std::vector<DataArrayDouble *>::const_iterator it=arrays.begin();it!=arrays.end();it++)
{
if(*it)
int nbCells=_discr_per_cell->getNumberOfTuples();
const int *array=old2NewBg;
if(check)
- array=DataArrayInt::checkAndPreparePermutation(old2NewBg,old2NewBg+nbCells);
+ array=DataArrayInt::CheckAndPreparePermutation(old2NewBg,old2NewBg+nbCells);
//
DataArrayInt *dpc=_discr_per_cell->renumber(array);
_discr_per_cell->decrRef();
{
const int *array=old2NewBg;
if(check)
- array=DataArrayInt::checkAndPreparePermutation(old2NewBg,old2NewBg+mesh->getNumberOfCells());
+ array=DataArrayInt::CheckAndPreparePermutation(old2NewBg,old2NewBg+mesh->getNumberOfCells());
int nbOfCells=_discr_per_cell->getNumberOfTuples();
int nbOfTuples=getNumberOfTuples(0);
const int *dcPtr=_discr_per_cell->getConstPointer();
{
const int *array=old2NewBg;
if(check)
- array=DataArrayInt::checkAndPreparePermutation(old2NewBg,old2NewBg+mesh->getNumberOfCells());
+ array=DataArrayInt::CheckAndPreparePermutation(old2NewBg,old2NewBg+mesh->getNumberOfCells());
int nbOfCells=mesh->getNumberOfCells();
int nbOfTuples=getNumberOfTuples(mesh);
int *array2=new int[nbOfTuples];//stores the final conversion array old2New to give to arrays in renumberInPlace.
_time_discr->sortPerTuple(asc);
}
-MEDCouplingFieldDouble *MEDCouplingFieldDouble::mergeFields(const MEDCouplingFieldDouble *f1, const MEDCouplingFieldDouble *f2) throw(INTERP_KERNEL::Exception)
+MEDCouplingFieldDouble *MEDCouplingFieldDouble::MergeFields(const MEDCouplingFieldDouble *f1, const MEDCouplingFieldDouble *f2) throw(INTERP_KERNEL::Exception)
{
if(!f1->areCompatibleForMerge(f2))
- throw INTERP_KERNEL::Exception("Fields are not compatible ; unable to apply mergeFields on them !");
+ throw INTERP_KERNEL::Exception("Fields are not compatible ; unable to apply MergeFields on them !");
const MEDCouplingMesh *m1=f1->getMesh();
const MEDCouplingMesh *m2=f2->getMesh();
MEDCouplingMesh *m=m1->mergeMyselfWith(m2);
return ret;
}
-MEDCouplingFieldDouble *MEDCouplingFieldDouble::mergeFields(const std::vector<const MEDCouplingFieldDouble *>& a) throw(INTERP_KERNEL::Exception)
+MEDCouplingFieldDouble *MEDCouplingFieldDouble::MergeFields(const std::vector<const MEDCouplingFieldDouble *>& a) throw(INTERP_KERNEL::Exception)
{
if(a.size()<=1)
- throw INTERP_KERNEL::Exception("FieldDouble::mergeFields : size of array must be > 1 !");
+ throw INTERP_KERNEL::Exception("FieldDouble::MergeFields : size of array must be > 1 !");
std::vector< MEDCouplingAutoRefCountObjectPtr<MEDCouplingUMesh> > ms(a.size());
std::vector< const MEDCouplingUMesh *> ms2(a.size());
std::vector< const MEDCouplingTimeDiscretization *> tds(a.size());
const MEDCouplingFieldDouble *ref=(*it++);
for(;it!=a.end();it++)
if(!ref->areCompatibleForMerge(*it))
- throw INTERP_KERNEL::Exception("Fields are not compatible ; unable to apply mergeFields on them !");
+ throw INTERP_KERNEL::Exception("Fields are not compatible ; unable to apply MergeFields on them !");
for(int i=0;i<(int)a.size();i++)
{
if(!a[i]->getMesh())
- throw INTERP_KERNEL::Exception("mergeFields : A field as no underlying mesh !");
+ throw INTERP_KERNEL::Exception("MergeFields : A field as no underlying mesh !");
ms[i]=a[i]->getMesh()->buildUnstructured();
ms2[i]=ms[i];
tds[i]=a[i]->_time_discr;
}
- MEDCouplingAutoRefCountObjectPtr<MEDCouplingUMesh> m=MEDCouplingUMesh::mergeUMeshes(ms2);
+ MEDCouplingAutoRefCountObjectPtr<MEDCouplingUMesh> m=MEDCouplingUMesh::MergeUMeshes(ms2);
MEDCouplingTimeDiscretization *td=tds[0]->aggregate(tds);
td->copyTinyAttrFrom(*(a[0]->_time_discr));
MEDCouplingFieldDouble *ret=new MEDCouplingFieldDouble(a[0]->getNature(),td,a[0]->_type->clone());
return ret;
}
-MEDCouplingFieldDouble *MEDCouplingFieldDouble::meldFields(const MEDCouplingFieldDouble *f1, const MEDCouplingFieldDouble *f2) throw(INTERP_KERNEL::Exception)
+MEDCouplingFieldDouble *MEDCouplingFieldDouble::MeldFields(const MEDCouplingFieldDouble *f1, const MEDCouplingFieldDouble *f2) throw(INTERP_KERNEL::Exception)
{
if(!f1->areCompatibleForMeld(f2))
- throw INTERP_KERNEL::Exception("Fields are not compatible ; unable to apply meldFields on them !");
+ throw INTERP_KERNEL::Exception("Fields are not compatible ; unable to apply MeldFields on them !");
MEDCouplingTimeDiscretization *td=f1->_time_discr->meld(f2->_time_discr);
td->copyTinyAttrFrom(*f1->_time_discr);
MEDCouplingFieldDouble *ret=new MEDCouplingFieldDouble(f1->getNature(),td,f1->_type->clone());
return ret;
}
-MEDCouplingFieldDouble *MEDCouplingFieldDouble::dotFields(const MEDCouplingFieldDouble *f1, const MEDCouplingFieldDouble *f2) throw(INTERP_KERNEL::Exception)
+MEDCouplingFieldDouble *MEDCouplingFieldDouble::DotFields(const MEDCouplingFieldDouble *f1, const MEDCouplingFieldDouble *f2) throw(INTERP_KERNEL::Exception)
{
if(!f1->areStrictlyCompatible(f2))
- throw INTERP_KERNEL::Exception("Fields are not compatible ; unable to apply dotFields on them !");
+ throw INTERP_KERNEL::Exception("Fields are not compatible ; unable to apply DotFields on them !");
MEDCouplingTimeDiscretization *td=f1->_time_discr->dot(f2->_time_discr);
td->copyTinyAttrFrom(*f1->_time_discr);
MEDCouplingFieldDouble *ret=new MEDCouplingFieldDouble(f1->getNature(),td,f1->_type->clone());
return ret;
}
-MEDCouplingFieldDouble *MEDCouplingFieldDouble::crossProductFields(const MEDCouplingFieldDouble *f1, const MEDCouplingFieldDouble *f2) throw(INTERP_KERNEL::Exception)
+MEDCouplingFieldDouble *MEDCouplingFieldDouble::CrossProductFields(const MEDCouplingFieldDouble *f1, const MEDCouplingFieldDouble *f2) throw(INTERP_KERNEL::Exception)
{
if(!f1->areStrictlyCompatible(f2))
- throw INTERP_KERNEL::Exception("Fields are not compatible ; unable to apply crossProductFields on them !");
+ throw INTERP_KERNEL::Exception("Fields are not compatible ; unable to apply CrossProductFields on them !");
MEDCouplingTimeDiscretization *td=f1->_time_discr->crossProduct(f2->_time_discr);
td->copyTinyAttrFrom(*f1->_time_discr);
MEDCouplingFieldDouble *ret=new MEDCouplingFieldDouble(f1->getNature(),td,f1->_type->clone());
return ret;
}
-MEDCouplingFieldDouble *MEDCouplingFieldDouble::maxFields(const MEDCouplingFieldDouble *f1, const MEDCouplingFieldDouble *f2) throw(INTERP_KERNEL::Exception)
+MEDCouplingFieldDouble *MEDCouplingFieldDouble::MaxFields(const MEDCouplingFieldDouble *f1, const MEDCouplingFieldDouble *f2) throw(INTERP_KERNEL::Exception)
{
if(!f1->areStrictlyCompatible(f2))
- throw INTERP_KERNEL::Exception("Fields are not compatible ; unable to apply maxFields on them !");
+ throw INTERP_KERNEL::Exception("Fields are not compatible ; unable to apply MaxFields on them !");
MEDCouplingTimeDiscretization *td=f1->_time_discr->max(f2->_time_discr);
td->copyTinyAttrFrom(*f1->_time_discr);
MEDCouplingFieldDouble *ret=new MEDCouplingFieldDouble(f1->getNature(),td,f1->_type->clone());
return ret;
}
-MEDCouplingFieldDouble *MEDCouplingFieldDouble::minFields(const MEDCouplingFieldDouble *f1, const MEDCouplingFieldDouble *f2) throw(INTERP_KERNEL::Exception)
+MEDCouplingFieldDouble *MEDCouplingFieldDouble::MinFields(const MEDCouplingFieldDouble *f1, const MEDCouplingFieldDouble *f2) throw(INTERP_KERNEL::Exception)
{
if(!f1->areStrictlyCompatible(f2))
- throw INTERP_KERNEL::Exception("Fields are not compatible ; unable to apply minFields on them !");
+ throw INTERP_KERNEL::Exception("Fields are not compatible ; unable to apply MinFields on them !");
MEDCouplingTimeDiscretization *td=f1->_time_discr->min(f2->_time_discr);
td->copyTinyAttrFrom(*f1->_time_discr);
MEDCouplingFieldDouble *ret=new MEDCouplingFieldDouble(f1->getNature(),td,f1->_type->clone());
return ret;
}
-MEDCouplingFieldDouble *MEDCouplingFieldDouble::addFields(const MEDCouplingFieldDouble *f1, const MEDCouplingFieldDouble *f2) throw(INTERP_KERNEL::Exception)
+MEDCouplingFieldDouble *MEDCouplingFieldDouble::AddFields(const MEDCouplingFieldDouble *f1, const MEDCouplingFieldDouble *f2) throw(INTERP_KERNEL::Exception)
{
if(!f1->areStrictlyCompatible(f2))
- throw INTERP_KERNEL::Exception("Fields are not compatible ; unable to apply addFields on them !");
+ throw INTERP_KERNEL::Exception("Fields are not compatible ; unable to apply AddFields on them !");
MEDCouplingTimeDiscretization *td=f1->_time_discr->add(f2->_time_discr);
td->copyTinyAttrFrom(*f1->_time_discr);
MEDCouplingFieldDouble *ret=new MEDCouplingFieldDouble(f1->getNature(),td,f1->_type->clone());
return *this;
}
-MEDCouplingFieldDouble *MEDCouplingFieldDouble::substractFields(const MEDCouplingFieldDouble *f1, const MEDCouplingFieldDouble *f2) throw(INTERP_KERNEL::Exception)
+MEDCouplingFieldDouble *MEDCouplingFieldDouble::SubstractFields(const MEDCouplingFieldDouble *f1, const MEDCouplingFieldDouble *f2) throw(INTERP_KERNEL::Exception)
{
if(!f1->areStrictlyCompatible(f2))
- throw INTERP_KERNEL::Exception("Fields are not compatible ; unable to apply substractFields on them !");
+ throw INTERP_KERNEL::Exception("Fields are not compatible ; unable to apply SubstractFields on them !");
MEDCouplingTimeDiscretization *td=f1->_time_discr->substract(f2->_time_discr);
td->copyTinyAttrFrom(*f1->_time_discr);
MEDCouplingFieldDouble *ret=new MEDCouplingFieldDouble(f1->getNature(),td,f1->_type->clone());
return *this;
}
-MEDCouplingFieldDouble *MEDCouplingFieldDouble::multiplyFields(const MEDCouplingFieldDouble *f1, const MEDCouplingFieldDouble *f2) throw(INTERP_KERNEL::Exception)
+MEDCouplingFieldDouble *MEDCouplingFieldDouble::MultiplyFields(const MEDCouplingFieldDouble *f1, const MEDCouplingFieldDouble *f2) throw(INTERP_KERNEL::Exception)
{
if(!f1->areCompatibleForMul(f2))
- throw INTERP_KERNEL::Exception("Fields are not compatible ; unable to apply multiplyFields on them !");
+ throw INTERP_KERNEL::Exception("Fields are not compatible ; unable to apply MultiplyFields on them !");
MEDCouplingTimeDiscretization *td=f1->_time_discr->multiply(f2->_time_discr);
td->copyTinyAttrFrom(*f1->_time_discr);
MEDCouplingFieldDouble *ret=new MEDCouplingFieldDouble(f1->getNature(),td,f1->_type->clone());
return *this;
}
-MEDCouplingFieldDouble *MEDCouplingFieldDouble::divideFields(const MEDCouplingFieldDouble *f1, const MEDCouplingFieldDouble *f2) throw(INTERP_KERNEL::Exception)
+MEDCouplingFieldDouble *MEDCouplingFieldDouble::DivideFields(const MEDCouplingFieldDouble *f1, const MEDCouplingFieldDouble *f2) throw(INTERP_KERNEL::Exception)
{
if(!f1->areCompatibleForDiv(f2))
- throw INTERP_KERNEL::Exception("Fields are not compatible ; unable to apply divideFields on them !");
+ throw INTERP_KERNEL::Exception("Fields are not compatible ; unable to apply DivideFields on them !");
MEDCouplingTimeDiscretization *td=f1->_time_discr->divide(f2->_time_discr);
td->copyTinyAttrFrom(*f1->_time_discr);
MEDCouplingFieldDouble *ret=new MEDCouplingFieldDouble(f1->getNature(),td,f1->_type->clone());
void setNature(NatureOfField nat) throw(INTERP_KERNEL::Exception);
void setTimeTolerance(double val) { _time_discr->setTimeTolerance(val); }
double getTimeTolerance() const { return _time_discr->getTimeTolerance(); }
+ void setIteration(int it) throw(INTERP_KERNEL::Exception) { _time_discr->setIteration(it); }
+ void setEndIteration(int it) throw(INTERP_KERNEL::Exception) { _time_discr->setEndIteration(it); }
+ void setOrder(int order) throw(INTERP_KERNEL::Exception) { _time_discr->setOrder(order); }
+ void setEndOrder(int order) throw(INTERP_KERNEL::Exception) { _time_discr->setEndOrder(order); }
+ void setTimeValue(double val) throw(INTERP_KERNEL::Exception) { _time_discr->setTimeValue(val); }
+ void setEndTimeValue(double val) throw(INTERP_KERNEL::Exception) { _time_discr->setEndTimeValue(val); }
void setTime(double val, int iteration, int order) { _time_discr->setTime(val,iteration,order); }
void setStartTime(double val, int iteration, int order) { _time_discr->setStartTime(val,iteration,order); }
void setEndTime(double val, int iteration, int order) { _time_discr->setEndTime(val,iteration,order); }
MEDCouplingFieldDouble *keepSelectedComponents(const std::vector<int>& compoIds) const throw(INTERP_KERNEL::Exception);
void setSelectedComponents(const MEDCouplingFieldDouble *f, const std::vector<int>& compoIds) throw(INTERP_KERNEL::Exception);
void sortPerTuple(bool asc) throw(INTERP_KERNEL::Exception);
- static MEDCouplingFieldDouble *mergeFields(const MEDCouplingFieldDouble *f1, const MEDCouplingFieldDouble *f2) throw(INTERP_KERNEL::Exception);
- static MEDCouplingFieldDouble *mergeFields(const std::vector<const MEDCouplingFieldDouble *>& a) throw(INTERP_KERNEL::Exception);
- static MEDCouplingFieldDouble *meldFields(const MEDCouplingFieldDouble *f1, const MEDCouplingFieldDouble *f2) throw(INTERP_KERNEL::Exception);
- static MEDCouplingFieldDouble *dotFields(const MEDCouplingFieldDouble *f1, const MEDCouplingFieldDouble *f2) throw(INTERP_KERNEL::Exception);
- MEDCouplingFieldDouble *dot(const MEDCouplingFieldDouble& other) const throw(INTERP_KERNEL::Exception) { return dotFields(this,&other); }
- static MEDCouplingFieldDouble *crossProductFields(const MEDCouplingFieldDouble *f1, const MEDCouplingFieldDouble *f2) throw(INTERP_KERNEL::Exception);
- MEDCouplingFieldDouble *crossProduct(const MEDCouplingFieldDouble& other) const throw(INTERP_KERNEL::Exception) { return crossProductFields(this,&other); }
- static MEDCouplingFieldDouble *maxFields(const MEDCouplingFieldDouble *f1, const MEDCouplingFieldDouble *f2) throw(INTERP_KERNEL::Exception);
- MEDCouplingFieldDouble *max(const MEDCouplingFieldDouble& other) const throw(INTERP_KERNEL::Exception) { return maxFields(this,&other); }
- static MEDCouplingFieldDouble *minFields(const MEDCouplingFieldDouble *f1, const MEDCouplingFieldDouble *f2) throw(INTERP_KERNEL::Exception);
- MEDCouplingFieldDouble *min(const MEDCouplingFieldDouble& other) const throw(INTERP_KERNEL::Exception) { return minFields(this,&other); }
- MEDCouplingFieldDouble *operator+(const MEDCouplingFieldDouble& other) const throw(INTERP_KERNEL::Exception) { return addFields(this,&other); }
+ static MEDCouplingFieldDouble *MergeFields(const MEDCouplingFieldDouble *f1, const MEDCouplingFieldDouble *f2) throw(INTERP_KERNEL::Exception);
+ static MEDCouplingFieldDouble *MergeFields(const std::vector<const MEDCouplingFieldDouble *>& a) throw(INTERP_KERNEL::Exception);
+ static MEDCouplingFieldDouble *MeldFields(const MEDCouplingFieldDouble *f1, const MEDCouplingFieldDouble *f2) throw(INTERP_KERNEL::Exception);
+ static MEDCouplingFieldDouble *DotFields(const MEDCouplingFieldDouble *f1, const MEDCouplingFieldDouble *f2) throw(INTERP_KERNEL::Exception);
+ MEDCouplingFieldDouble *dot(const MEDCouplingFieldDouble& other) const throw(INTERP_KERNEL::Exception) { return DotFields(this,&other); }
+ static MEDCouplingFieldDouble *CrossProductFields(const MEDCouplingFieldDouble *f1, const MEDCouplingFieldDouble *f2) throw(INTERP_KERNEL::Exception);
+ MEDCouplingFieldDouble *crossProduct(const MEDCouplingFieldDouble& other) const throw(INTERP_KERNEL::Exception) { return CrossProductFields(this,&other); }
+ static MEDCouplingFieldDouble *MaxFields(const MEDCouplingFieldDouble *f1, const MEDCouplingFieldDouble *f2) throw(INTERP_KERNEL::Exception);
+ MEDCouplingFieldDouble *max(const MEDCouplingFieldDouble& other) const throw(INTERP_KERNEL::Exception) { return MaxFields(this,&other); }
+ static MEDCouplingFieldDouble *MinFields(const MEDCouplingFieldDouble *f1, const MEDCouplingFieldDouble *f2) throw(INTERP_KERNEL::Exception);
+ MEDCouplingFieldDouble *min(const MEDCouplingFieldDouble& other) const throw(INTERP_KERNEL::Exception) { return MinFields(this,&other); }
+ MEDCouplingFieldDouble *operator+(const MEDCouplingFieldDouble& other) const throw(INTERP_KERNEL::Exception) { return AddFields(this,&other); }
const MEDCouplingFieldDouble &operator+=(const MEDCouplingFieldDouble& other) throw(INTERP_KERNEL::Exception);
- static MEDCouplingFieldDouble *addFields(const MEDCouplingFieldDouble *f1, const MEDCouplingFieldDouble *f2) throw(INTERP_KERNEL::Exception);
- MEDCouplingFieldDouble *operator-(const MEDCouplingFieldDouble& other) const throw(INTERP_KERNEL::Exception) { return substractFields(this,&other); }
+ static MEDCouplingFieldDouble *AddFields(const MEDCouplingFieldDouble *f1, const MEDCouplingFieldDouble *f2) throw(INTERP_KERNEL::Exception);
+ MEDCouplingFieldDouble *operator-(const MEDCouplingFieldDouble& other) const throw(INTERP_KERNEL::Exception) { return SubstractFields(this,&other); }
const MEDCouplingFieldDouble &operator-=(const MEDCouplingFieldDouble& other) throw(INTERP_KERNEL::Exception);
- static MEDCouplingFieldDouble *substractFields(const MEDCouplingFieldDouble *f1, const MEDCouplingFieldDouble *f2) throw(INTERP_KERNEL::Exception);
- MEDCouplingFieldDouble *operator*(const MEDCouplingFieldDouble& other) const throw(INTERP_KERNEL::Exception) { return multiplyFields(this,&other); }
+ static MEDCouplingFieldDouble *SubstractFields(const MEDCouplingFieldDouble *f1, const MEDCouplingFieldDouble *f2) throw(INTERP_KERNEL::Exception);
+ MEDCouplingFieldDouble *operator*(const MEDCouplingFieldDouble& other) const throw(INTERP_KERNEL::Exception) { return MultiplyFields(this,&other); }
const MEDCouplingFieldDouble &operator*=(const MEDCouplingFieldDouble& other) throw(INTERP_KERNEL::Exception);
- static MEDCouplingFieldDouble *multiplyFields(const MEDCouplingFieldDouble *f1, const MEDCouplingFieldDouble *f2) throw(INTERP_KERNEL::Exception);
- MEDCouplingFieldDouble *operator/(const MEDCouplingFieldDouble& other) const throw(INTERP_KERNEL::Exception) { return divideFields(this,&other); }
+ static MEDCouplingFieldDouble *MultiplyFields(const MEDCouplingFieldDouble *f1, const MEDCouplingFieldDouble *f2) throw(INTERP_KERNEL::Exception);
+ MEDCouplingFieldDouble *operator/(const MEDCouplingFieldDouble& other) const throw(INTERP_KERNEL::Exception) { return DivideFields(this,&other); }
const MEDCouplingFieldDouble &operator/=(const MEDCouplingFieldDouble& other) throw(INTERP_KERNEL::Exception);
- static MEDCouplingFieldDouble *divideFields(const MEDCouplingFieldDouble *f1, const MEDCouplingFieldDouble *f2) throw(INTERP_KERNEL::Exception);
+ static MEDCouplingFieldDouble *DivideFields(const MEDCouplingFieldDouble *f1, const MEDCouplingFieldDouble *f2) throw(INTERP_KERNEL::Exception);
private:
MEDCouplingFieldDouble(TypeOfField type, TypeOfTimeDiscretization td);
MEDCouplingFieldDouble(const MEDCouplingFieldDouble& other, bool deepCpy);
#include <set>
#include <cmath>
+#include <limits>
#include <numeric>
#include <functional>
return true;
}
+void DataArrayDouble::sort() throw(INTERP_KERNEL::Exception)
+{
+ checkAllocated();
+ if(getNumberOfComponents()!=1)
+ throw INTERP_KERNEL::Exception("DataArrayDouble::sort : only supported with 'this' array with ONE component !");
+ _mem.sort();
+}
+
std::string DataArrayDouble::repr() const
{
std::ostringstream ret;
int nbt=getNumberOfTuples();
if(tupleIdBg<0)
throw INTERP_KERNEL::Exception("DataArrayInt::substr : The tupleIdBg parameter must be greater than 0 !");
- if(tupleIdBg>=nbt)
- throw INTERP_KERNEL::Exception("DataArrayInt::substr : The tupleIdBg parameter is greater or equal than number of tuples !");
+ if(tupleIdBg>nbt)
+ throw INTERP_KERNEL::Exception("DataArrayInt::substr : The tupleIdBg parameter is greater than number of tuples !");
int trueEnd=tupleIdEnd;
if(tupleIdEnd!=-1)
{
return ret;
}
+/*!
+ * Contrary to DataArrayDouble::changeNbOfComponents method this method is \b not const. The content
+ * This method \b do \b not change the content of data but changes the splitting of this data seen by the caller.
+ * This method makes the assumption that 'this' is already allocated. If not an exception will be thrown.
+ * This method checks that getNbOfElems()%newNbOfCompo==0. If not an exception will be throw !
+ * This method erases all components info set before call !
+ */
+void DataArrayDouble::rearrange(int newNbOfCompo) throw(INTERP_KERNEL::Exception)
+{
+ checkAllocated();
+ int nbOfElems=getNbOfElems();
+ if(nbOfElems%newNbOfCompo!=0)
+ throw INTERP_KERNEL::Exception("DataArrayDouble::rearrange : nbOfElems%newNbOfCompo!=0 !");
+ _nb_of_tuples=nbOfElems/newNbOfCompo;
+ _info_on_compo.clear();
+ _info_on_compo.resize(newNbOfCompo);
+ declareAsNew();
+}
+
DataArrayDouble *DataArrayDouble::keepSelectedComponents(const std::vector<int>& compoIds) const throw(INTERP_KERNEL::Exception)
{
checkAllocated();
nc[nbOfCompo*i+compoIds[j]]=*ac;
}
-void DataArrayDouble::setArrayIn(DataArrayDouble *newArray, DataArrayDouble* &arrayToSet)
+void DataArrayDouble::SetArrayIn(DataArrayDouble *newArray, DataArrayDouble* &arrayToSet)
{
if(newArray!=arrayToSet)
{
return ret;
}
-DataArrayDouble *DataArrayDouble::aggregate(const DataArrayDouble *a1, const DataArrayDouble *a2) throw(INTERP_KERNEL::Exception)
+DataArrayDouble *DataArrayDouble::Aggregate(const DataArrayDouble *a1, const DataArrayDouble *a2) throw(INTERP_KERNEL::Exception)
{
std::vector<const DataArrayDouble *> tmp(2);
tmp[0]=a1; tmp[1]=a2;
- return aggregate(tmp);
+ return Aggregate(tmp);
}
-DataArrayDouble *DataArrayDouble::aggregate(const std::vector<const DataArrayDouble *>& a) throw(INTERP_KERNEL::Exception)
+DataArrayDouble *DataArrayDouble::Aggregate(const std::vector<const DataArrayDouble *>& a) throw(INTERP_KERNEL::Exception)
{
if(a.empty())
- throw INTERP_KERNEL::Exception("DataArrayDouble::aggregate : input list must be NON EMPTY !");
+ throw INTERP_KERNEL::Exception("DataArrayDouble::Aggregate : input list must be NON EMPTY !");
std::vector<const DataArrayDouble *>::const_iterator it=a.begin();
int nbOfComp=(*it)->getNumberOfComponents();
int nbt=(*it++)->getNumberOfTuples();
for(int i=1;it!=a.end();it++,i++)
{
if((*it)->getNumberOfComponents()!=nbOfComp)
- throw INTERP_KERNEL::Exception("DataArrayDouble::aggregate : Nb of components mismatch for array aggregation !");
+ throw INTERP_KERNEL::Exception("DataArrayDouble::Aggregate : Nb of components mismatch for array aggregation !");
nbt+=(*it)->getNumberOfTuples();
}
DataArrayDouble *ret=DataArrayDouble::New();
return ret;
}
-DataArrayDouble *DataArrayDouble::meld(const DataArrayDouble *a1, const DataArrayDouble *a2) throw(INTERP_KERNEL::Exception)
+DataArrayDouble *DataArrayDouble::Meld(const DataArrayDouble *a1, const DataArrayDouble *a2) throw(INTERP_KERNEL::Exception)
{
std::vector<const DataArrayDouble *> arr(2);
arr[0]=a1; arr[1]=a2;
- return meld(arr);
+ return Meld(arr);
}
-DataArrayDouble *DataArrayDouble::meld(const std::vector<const DataArrayDouble *>& a) throw(INTERP_KERNEL::Exception)
+DataArrayDouble *DataArrayDouble::Meld(const std::vector<const DataArrayDouble *>& a) throw(INTERP_KERNEL::Exception)
{
if(a.empty())
- throw INTERP_KERNEL::Exception("DataArrayDouble::meld : array must be NON empty !");
+ throw INTERP_KERNEL::Exception("DataArrayDouble::Meld : array must be NON empty !");
std::vector<const DataArrayDouble *>::const_iterator it;
for(it=a.begin();it!=a.end();it++)
(*it)->checkAllocated();
for(int i=1;it!=a.end();it++,i++)
{
if(nbOfTuples!=(*it)->getNumberOfTuples())
- throw INTERP_KERNEL::Exception("DataArrayDouble::meld : mismatch of number of tuples !");
+ throw INTERP_KERNEL::Exception("DataArrayDouble::Meld : mismatch of number of tuples !");
nbc[i]=(*it)->getNumberOfComponents();
pts[i]=(*it)->getConstPointer();
}
return ret;
}
-DataArrayDouble *DataArrayDouble::dot(const DataArrayDouble *a1, const DataArrayDouble *a2) throw(INTERP_KERNEL::Exception)
+DataArrayDouble *DataArrayDouble::Dot(const DataArrayDouble *a1, const DataArrayDouble *a2) throw(INTERP_KERNEL::Exception)
{
a1->checkAllocated();
a2->checkAllocated();
int nbOfComp=a1->getNumberOfComponents();
if(nbOfComp!=a2->getNumberOfComponents())
- throw INTERP_KERNEL::Exception("Nb of components mismatch for array dot !");
+ throw INTERP_KERNEL::Exception("Nb of components mismatch for array Dot !");
int nbOfTuple=a1->getNumberOfTuples();
if(nbOfTuple!=a2->getNumberOfTuples())
- throw INTERP_KERNEL::Exception("Nb of tuples mismatch for array dot !");
+ throw INTERP_KERNEL::Exception("Nb of tuples mismatch for array Dot !");
DataArrayDouble *ret=DataArrayDouble::New();
ret->alloc(nbOfTuple,1);
double *retPtr=ret->getPointer();
return ret;
}
-DataArrayDouble *DataArrayDouble::crossProduct(const DataArrayDouble *a1, const DataArrayDouble *a2) throw(INTERP_KERNEL::Exception)
+DataArrayDouble *DataArrayDouble::CrossProduct(const DataArrayDouble *a1, const DataArrayDouble *a2) throw(INTERP_KERNEL::Exception)
{
int nbOfComp=a1->getNumberOfComponents();
if(nbOfComp!=a2->getNumberOfComponents())
return ret;
}
-DataArrayDouble *DataArrayDouble::max(const DataArrayDouble *a1, const DataArrayDouble *a2) throw(INTERP_KERNEL::Exception)
+DataArrayDouble *DataArrayDouble::Max(const DataArrayDouble *a1, const DataArrayDouble *a2) throw(INTERP_KERNEL::Exception)
{
int nbOfComp=a1->getNumberOfComponents();
if(nbOfComp!=a2->getNumberOfComponents())
- throw INTERP_KERNEL::Exception("Nb of components mismatch for array max !");
+ throw INTERP_KERNEL::Exception("Nb of components mismatch for array Max !");
int nbOfTuple=a1->getNumberOfTuples();
if(nbOfTuple!=a2->getNumberOfTuples())
- throw INTERP_KERNEL::Exception("Nb of tuples mismatch for array max !");
+ throw INTERP_KERNEL::Exception("Nb of tuples mismatch for array Max !");
DataArrayDouble *ret=DataArrayDouble::New();
ret->alloc(nbOfTuple,nbOfComp);
double *retPtr=ret->getPointer();
return ret;
}
-DataArrayDouble *DataArrayDouble::min(const DataArrayDouble *a1, const DataArrayDouble *a2) throw(INTERP_KERNEL::Exception)
+DataArrayDouble *DataArrayDouble::Min(const DataArrayDouble *a1, const DataArrayDouble *a2) throw(INTERP_KERNEL::Exception)
{
int nbOfComp=a1->getNumberOfComponents();
if(nbOfComp!=a2->getNumberOfComponents())
return ret;
}
-DataArrayDouble *DataArrayDouble::add(const DataArrayDouble *a1, const DataArrayDouble *a2) throw(INTERP_KERNEL::Exception)
+DataArrayDouble *DataArrayDouble::Add(const DataArrayDouble *a1, const DataArrayDouble *a2) throw(INTERP_KERNEL::Exception)
{
int nbOfComp=a1->getNumberOfComponents();
if(nbOfComp!=a2->getNumberOfComponents())
declareAsNew();
}
-DataArrayDouble *DataArrayDouble::substract(const DataArrayDouble *a1, const DataArrayDouble *a2) throw(INTERP_KERNEL::Exception)
+DataArrayDouble *DataArrayDouble::Substract(const DataArrayDouble *a1, const DataArrayDouble *a2) throw(INTERP_KERNEL::Exception)
{
int nbOfComp=a1->getNumberOfComponents();
if(nbOfComp!=a2->getNumberOfComponents())
- throw INTERP_KERNEL::Exception("Nb of components mismatch for array substract !");
+ throw INTERP_KERNEL::Exception("Nb of components mismatch for array Substract !");
int nbOfTuple=a1->getNumberOfTuples();
if(nbOfTuple!=a2->getNumberOfTuples())
- throw INTERP_KERNEL::Exception("Nb of tuples mismatch for array substract !");
+ throw INTERP_KERNEL::Exception("Nb of tuples mismatch for array Substract !");
DataArrayDouble *ret=DataArrayDouble::New();
ret->alloc(nbOfTuple,nbOfComp);
std::transform(a1->getConstPointer(),a1->getConstPointer()+nbOfTuple*nbOfComp,a2->getConstPointer(),ret->getPointer(),std::minus<double>());
declareAsNew();
}
-DataArrayDouble *DataArrayDouble::multiply(const DataArrayDouble *a1, const DataArrayDouble *a2) throw(INTERP_KERNEL::Exception)
+DataArrayDouble *DataArrayDouble::Multiply(const DataArrayDouble *a1, const DataArrayDouble *a2) throw(INTERP_KERNEL::Exception)
{
int nbOfTuple=a1->getNumberOfTuples();
int nbOfTuple2=a2->getNumberOfTuples();
declareAsNew();
}
-DataArrayDouble *DataArrayDouble::divide(const DataArrayDouble *a1, const DataArrayDouble *a2) throw(INTERP_KERNEL::Exception)
+DataArrayDouble *DataArrayDouble::Divide(const DataArrayDouble *a1, const DataArrayDouble *a2) throw(INTERP_KERNEL::Exception)
{
int nbOfTuple=a1->getNumberOfTuples();
int nbOfTuple2=a2->getNumberOfTuples();
return _mem.isEqual(other._mem,0);
}
+bool DataArrayInt::isEqualWithoutConsideringStrAndOrder(const DataArrayInt& other) const throw(INTERP_KERNEL::Exception)
+{
+ MEDCouplingAutoRefCountObjectPtr<DataArrayInt> a=deepCpy();
+ MEDCouplingAutoRefCountObjectPtr<DataArrayInt> b=other.deepCpy();
+ a->sort();
+ b->sort();
+ return a->isEqualWithoutConsideringStr(*b);
+}
+
+void DataArrayInt::sort() throw(INTERP_KERNEL::Exception)
+{
+ checkAllocated();
+ if(getNumberOfComponents()!=1)
+ throw INTERP_KERNEL::Exception("DataArrayInt::sort : only supported with 'this' array with ONE component !");
+ _mem.sort();
+}
+
+/*!
+ * This method expects that 'this' and 'other' have the same number of tuples and exactly one component both. If not an exception will be thrown.
+ * This method retrieves a newly created array with same number of tuples than 'this' and 'other' with one component.
+ * The returned array 'ret' contains the correspondance from 'this' to 'other' that is to say for every i so that 0<=i<getNumberOfTuples()
+ * other.getIJ(i,0)==this->getIJ(ret->getIJ(i),0)
+ * If such permutation is not possible because it exists some elements in 'other' not in 'this', an exception will be thrown.
+ */
+DataArrayInt *DataArrayInt::buildPermutationArr(const DataArrayInt& other) const throw(INTERP_KERNEL::Exception)
+{
+ if(getNumberOfComponents()!=1 || other.getNumberOfComponents()!=1)
+ throw INTERP_KERNEL::Exception("DataArrayInt::buildPermutationArr : 'this' and 'other' have to have exactly ONE component !");
+ int nbTuple=getNumberOfTuples();
+ if(nbTuple!=other.getNumberOfTuples())
+ throw INTERP_KERNEL::Exception("DataArrayInt::buildPermutationArr : 'this' and 'other' must have the same number of tuple !");
+ MEDCouplingAutoRefCountObjectPtr<DataArrayInt> ret=DataArrayInt::New();
+ ret->alloc(nbTuple,1);
+ ret->fillWithValue(-1);
+ const int *pt=getConstPointer();
+ std::map<int,int> mm;
+ for(int i=0;i<nbTuple;i++)
+ mm[pt[i]]=i;
+ pt=other.getConstPointer();
+ int *retToFill=ret->getPointer();
+ for(int i=0;i<nbTuple;i++)
+ {
+ std::map<int,int>::const_iterator it=mm.find(pt[i]);
+ if(it==mm.end())
+ {
+ std::ostringstream oss; oss << "DataArrayInt::buildPermutationArr : Arrays mismatch : element (" << pt[i] << ") in 'other' not findable in 'this' !";
+ throw INTERP_KERNEL::Exception(oss.str().c_str());
+ }
+ retToFill[i]=(*it).second;
+ }
+ ret->incrRef();
+ return ret;
+}
+
void DataArrayInt::useArray(const int *array, bool ownership, DeallocType type, int nbOfTuple, int nbOfCompo)
{
_nb_of_tuples=nbOfTuple;
int nbt=getNumberOfTuples();
if(tupleIdBg<0)
throw INTERP_KERNEL::Exception("DataArrayInt::substr : The tupleIdBg parameter must be greater than 0 !");
- if(tupleIdBg>=nbt)
- throw INTERP_KERNEL::Exception("DataArrayInt::substr : The tupleIdBg parameter is greater or equal than number of tuples !");
+ if(tupleIdBg>nbt)
+ throw INTERP_KERNEL::Exception("DataArrayInt::substr : The tupleIdBg parameter is greater than number of tuples !");
int trueEnd=tupleIdEnd;
if(tupleIdEnd!=-1)
{
return ret;
}
+/*!
+ * Contrary to DataArrayInt::changeNbOfComponents method this method is \b not const. The content
+ * This method \b do \b not change the content of data but changes the splitting of this data seen by the caller.
+ * This method makes the assumption that 'this' is already allocated. If not an exception will be thrown.
+ * This method checks that getNbOfElems()%newNbOfCompo==0. If not an exception will be throw !
+ * This method erases all components info set before call !
+ */
+void DataArrayInt::rearrange(int newNbOfCompo) throw(INTERP_KERNEL::Exception)
+{
+ checkAllocated();
+ int nbOfElems=getNbOfElems();
+ if(nbOfElems%newNbOfCompo!=0)
+ throw INTERP_KERNEL::Exception("DataArrayInt::rearrange : nbOfElems%newNbOfCompo!=0 !");
+ _nb_of_tuples=nbOfElems/newNbOfCompo;
+ _info_on_compo.clear();
+ _info_on_compo.resize(newNbOfCompo);
+ declareAsNew();
+}
+
/*!
* This method builds a new instance of DataArrayInt (to deal with) that is reduction or an extension of 'this'.
* if 'newNbOfComp' < this->getNumberOfComponents() a reduction is done and for each tuple 'newNbOfComp' first components are kept.
nc[nbOfCompo*i+compoIds[j]]=*ac;
}
-void DataArrayInt::setArrayIn(DataArrayInt *newArray, DataArrayInt* &arrayToSet)
+void DataArrayInt::SetArrayIn(DataArrayInt *newArray, DataArrayInt* &arrayToSet)
{
if(newArray!=arrayToSet)
{
return ret;
}
-DataArrayInt *DataArrayInt::aggregate(const DataArrayInt *a1, const DataArrayInt *a2, int offsetA2)
+DataArrayInt *DataArrayInt::Aggregate(const DataArrayInt *a1, const DataArrayInt *a2, int offsetA2)
{
int nbOfComp=a1->getNumberOfComponents();
if(nbOfComp!=a2->getNumberOfComponents())
- throw INTERP_KERNEL::Exception("Nb of components mismatch for array aggregation !");
+ throw INTERP_KERNEL::Exception("Nb of components mismatch for array Aggregation !");
int nbOfTuple1=a1->getNumberOfTuples();
int nbOfTuple2=a2->getNumberOfTuples();
DataArrayInt *ret=DataArrayInt::New();
return ret;
}
+DataArrayInt *DataArrayInt::Aggregate(const std::vector<const DataArrayInt *>& a) throw(INTERP_KERNEL::Exception)
+{
+ if(a.empty())
+ throw INTERP_KERNEL::Exception("DataArrayInt::Aggregate : input list must be NON EMPTY !");
+ std::vector<const DataArrayInt *>::const_iterator it=a.begin();
+ int nbOfComp=(*it)->getNumberOfComponents();
+ int nbt=(*it++)->getNumberOfTuples();
+ for(int i=1;it!=a.end();it++,i++)
+ {
+ if((*it)->getNumberOfComponents()!=nbOfComp)
+ throw INTERP_KERNEL::Exception("DataArrayInt::Aggregate : Nb of components mismatch for array aggregation !");
+ nbt+=(*it)->getNumberOfTuples();
+ }
+ DataArrayInt *ret=DataArrayInt::New();
+ ret->alloc(nbt,nbOfComp);
+ int *pt=ret->getPointer();
+ for(it=a.begin();it!=a.end();it++)
+ pt=std::copy((*it)->getConstPointer(),(*it)->getConstPointer()+(*it)->getNbOfElems(),pt);
+ ret->copyStringInfoFrom(*(a[0]));
+ return ret;
+}
+
int DataArrayInt::getMaxValue(int& tupleId) const throw(INTERP_KERNEL::Exception)
{
if(getNumberOfComponents()!=1)
return *loc;
}
-DataArrayInt *DataArrayInt::meld(const DataArrayInt *a1, const DataArrayInt *a2) throw(INTERP_KERNEL::Exception)
+void DataArrayInt::applyLin(int a, int b, int compoId) throw(INTERP_KERNEL::Exception)
+{
+ checkAllocated();
+ int *ptr=getPointer()+compoId;
+ int nbOfComp=getNumberOfComponents();
+ int nbOfTuple=getNumberOfTuples();
+ for(int i=0;i<nbOfTuple;i++,ptr+=nbOfComp)
+ *ptr=a*(*ptr)+b;
+ declareAsNew();
+}
+
+DataArrayInt *DataArrayInt::Meld(const DataArrayInt *a1, const DataArrayInt *a2) throw(INTERP_KERNEL::Exception)
{
std::vector<const DataArrayInt *> arr(2);
arr[0]=a1; arr[1]=a2;
- return meld(arr);
+ return Meld(arr);
}
-DataArrayInt *DataArrayInt::meld(const std::vector<const DataArrayInt *>& a) throw(INTERP_KERNEL::Exception)
+DataArrayInt *DataArrayInt::Meld(const std::vector<const DataArrayInt *>& a) throw(INTERP_KERNEL::Exception)
{
if(a.empty())
- throw INTERP_KERNEL::Exception("DataArrayInt::meld : array must be NON empty !");
+ throw INTERP_KERNEL::Exception("DataArrayInt::Meld : array must be NON empty !");
std::vector<const DataArrayInt *>::const_iterator it;
for(it=a.begin();it!=a.end();it++)
(*it)->checkAllocated();
* @param newNb specifies size of whole set. Must be at least equal to max eltid in 'groups'.
* @return an array of size newNb specifying fid of each item.
*/
-DataArrayInt *DataArrayInt::makePartition(const std::vector<DataArrayInt *>& groups, int newNb, std::vector< std::vector<int> >& fidsOfGroups)
+DataArrayInt *DataArrayInt::MakePartition(const std::vector<const DataArrayInt *>& groups, int newNb, std::vector< std::vector<int> >& fidsOfGroups)
{
DataArrayInt *ret=DataArrayInt::New();
ret->alloc(newNb,1);
int *retPtr=ret->getPointer();
std::fill(retPtr,retPtr+newNb,0);
int fid=1;
- for(std::vector<DataArrayInt *>::const_iterator iter=groups.begin();iter!=groups.end();iter++)
+ for(std::vector<const DataArrayInt *>::const_iterator iter=groups.begin();iter!=groups.end();iter++)
{
const int *ptr=(*iter)->getConstPointer();
int nbOfElem=(*iter)->getNbOfElems();
fidsOfGroups.clear();
fidsOfGroups.resize(groups.size());
int grId=0;
- for(std::vector<DataArrayInt *>::const_iterator iter=groups.begin();iter!=groups.end();iter++,grId++)
+ for(std::vector<const DataArrayInt *>::const_iterator iter=groups.begin();iter!=groups.end();iter++,grId++)
{
std::set<int> tmp;
const int *ptr=(*iter)->getConstPointer();
return ret;
}
+DataArrayInt *DataArrayInt::BuildUnion(const std::vector<const DataArrayInt *>& a) throw(INTERP_KERNEL::Exception)
+{
+ int valm=std::numeric_limits<int>::max();
+ for(std::vector<const DataArrayInt *>::const_iterator it=a.begin();it!=a.end();it++)
+ {
+ (*it)->checkAllocated();
+ if((*it)->getNumberOfComponents()!=1)
+ throw INTERP_KERNEL::Exception("DataArrayInt::BuildUnion : only single component allowed !");
+ int tmp1;
+ valm=std::min((*it)->getMinValue(tmp1),valm);
+ }
+ if(valm<0)
+ throw INTERP_KERNEL::Exception("DataArrayInt::BuildUnion : a negative value has been detected !");
+ //
+ std::set<int> r;
+ for(std::vector<const DataArrayInt *>::const_iterator it=a.begin();it!=a.end();it++)
+ {
+ const int *pt=(*it)->getConstPointer();
+ int nbOfTuples=(*it)->getNumberOfTuples();
+ r.insert(pt,pt+nbOfTuples);
+ }
+ DataArrayInt *ret=DataArrayInt::New();
+ ret->alloc(r.size(),1);
+ std::copy(r.begin(),r.end(),ret->getPointer());
+ return ret;
+}
+
+DataArrayInt *DataArrayInt::BuildIntersection(const std::vector<const DataArrayInt *>& a) throw(INTERP_KERNEL::Exception)
+{
+ int valm=std::numeric_limits<int>::max();
+ for(std::vector<const DataArrayInt *>::const_iterator it=a.begin();it!=a.end();it++)
+ {
+ (*it)->checkAllocated();
+ if((*it)->getNumberOfComponents()!=1)
+ throw INTERP_KERNEL::Exception("DataArrayInt::BuildUnion : only single component allowed !");
+ int tmp1;
+ valm=std::min((*it)->getMinValue(tmp1),valm);
+ }
+ if(valm<0)
+ throw INTERP_KERNEL::Exception("DataArrayInt::BuildUnion : a negative value has been detected !");
+ //
+ std::set<int> r;
+ for(std::vector<const DataArrayInt *>::const_iterator it=a.begin();it!=a.end();it++)
+ {
+ const int *pt=(*it)->getConstPointer();
+ int nbOfTuples=(*it)->getNumberOfTuples();
+ std::set<int> s1(pt,pt+nbOfTuples);
+ if(it!=a.begin())
+ {
+ std::set<int> r2;
+ std::set_intersection(r.begin(),r.end(),s1.begin(),s1.end(),inserter(r2,r2.end()));
+ r=r2;
+ }
+ else
+ r=s1;
+ }
+ DataArrayInt *ret=DataArrayInt::New();
+ ret->alloc(r.size(),1);
+ std::copy(r.begin(),r.end(),ret->getPointer());
+ return ret;
+}
+
DataArrayInt *DataArrayInt::buildComplement(int nbOfElement) const throw(INTERP_KERNEL::Exception)
{
checkAllocated();
DataArrayInt *DataArrayInt::buildUnion(const DataArrayInt *other) const throw(INTERP_KERNEL::Exception)
{
- checkAllocated();
- other->checkAllocated();
- if(getNumberOfComponents()!=1)
- throw INTERP_KERNEL::Exception("DataArrayInt::buildUnion : only single component allowed !");
- if(other->getNumberOfComponents()!=1)
- throw INTERP_KERNEL::Exception("DataArrayInt::buildUnion : only single component allowed for other type !");
- int tmp1;
- int valm=getMinValue(tmp1);
- valm=std::min(other->getMinValue(tmp1),valm);
- if(valm<0)
- throw INTERP_KERNEL::Exception("DataArrayInt::buildUnion : a negative value has been detected !");
- //
- const int *pt=getConstPointer();
- int nbOfTuples=getNumberOfTuples();
- std::set<int> s1(pt,pt+nbOfTuples);
- pt=other->getConstPointer();
- nbOfTuples=other->getNumberOfTuples();
- std::set<int> s2(pt,pt+nbOfTuples);
- std::vector<int> r;
- std::set_union(s1.begin(),s1.end(),s2.begin(),s2.end(),std::back_insert_iterator< std::vector<int> >(r));
- DataArrayInt *ret=DataArrayInt::New();
- ret->alloc(r.size(),1);
- std::copy(r.begin(),r.end(),ret->getPointer());
- return ret;
+ std::vector<const DataArrayInt *>arrs(2);
+ arrs[0]=this; arrs[1]=other;
+ return BuildUnion(arrs);
}
DataArrayInt *DataArrayInt::buildIntersection(const DataArrayInt *other) const throw(INTERP_KERNEL::Exception)
{
- checkAllocated();
- other->checkAllocated();
- if(getNumberOfComponents()!=1)
- throw INTERP_KERNEL::Exception("DataArrayInt::buildIntersection : only single component allowed !");
- if(other->getNumberOfComponents()!=1)
- throw INTERP_KERNEL::Exception("DataArrayInt::buildIntersection : only single component allowed for other type !");
- int tmp1;
- int valm=getMinValue(tmp1);
- valm=std::min(other->getMinValue(tmp1),valm);
- if(valm<0)
- throw INTERP_KERNEL::Exception("DataArrayInt::buildIntersection : a negative value has been detected !");
- //
- const int *pt=getConstPointer();
- int nbOfTuples=getNumberOfTuples();
- std::set<int> s1(pt,pt+nbOfTuples);
- pt=other->getConstPointer();
- nbOfTuples=other->getNumberOfTuples();
- std::set<int> s2(pt,pt+nbOfTuples);
- std::vector<int> r;
- std::set_intersection(s1.begin(),s1.end(),s2.begin(),s2.end(),std::back_insert_iterator< std::vector<int> >(r));
- DataArrayInt *ret=DataArrayInt::New();
- ret->alloc(r.size(),1);
- std::copy(r.begin(),r.end(),ret->getPointer());
- return ret;
+ std::vector<const DataArrayInt *>arrs(2);
+ arrs[0]=this; arrs[1]=other;
+ return BuildIntersection(arrs);
}
/*!
return ret;
}
-int *DataArrayInt::checkAndPreparePermutation(const int *start, const int *end)
+/*!
+ * This method returns all different values found in 'this'.
+ */
+std::set<int> DataArrayInt::getDifferentValues() const throw(INTERP_KERNEL::Exception)
+{
+ checkAllocated();
+ std::set<int> ret;
+ ret.insert(getConstPointer(),getConstPointer()+getNbOfElems());
+ return ret;
+}
+
+int *DataArrayInt::CheckAndPreparePermutation(const int *start, const int *end)
{
int sz=std::distance(start,end);
int *ret=new int[sz];
#include "MEDCouplingRefCountObject.hxx"
#include "InterpKernelException.hxx"
+#include <set>
#include <string>
#include <vector>
#include <iterator>
void fillWithValue(const T& val);
T *fromNoInterlace(int nbOfComp) const;
T *toNoInterlace(int nbOfComp) const;
+ void sort();
void alloc(int nbOfElements);
void reAlloc(int newNbOfElements);
void useArray(const T *array, bool ownership, DeallocType type, int nbOfElem);
MEDCOUPLING_EXPORT void fillWithValue(double val) throw(INTERP_KERNEL::Exception);
MEDCOUPLING_EXPORT void iota(double init=0.) throw(INTERP_KERNEL::Exception);
MEDCOUPLING_EXPORT bool isUniform(double val, double eps) const;
+ MEDCOUPLING_EXPORT void sort() throw(INTERP_KERNEL::Exception);
MEDCOUPLING_EXPORT std::string repr() const;
MEDCOUPLING_EXPORT std::string reprZip() const;
MEDCOUPLING_EXPORT void reprStream(std::ostream& stream) const;
MEDCOUPLING_EXPORT DataArrayDouble *selectByTupleId(const int *new2OldBg, const int *new2OldEnd) const;
MEDCOUPLING_EXPORT DataArrayDouble *selectByTupleIdSafe(const int *new2OldBg, const int *new2OldEnd) const throw(INTERP_KERNEL::Exception);
MEDCOUPLING_EXPORT DataArrayDouble *substr(int tupleIdBg, int tupleIdEnd=-1) const throw(INTERP_KERNEL::Exception);
+ MEDCOUPLING_EXPORT void rearrange(int newNbOfCompo) throw(INTERP_KERNEL::Exception);
MEDCOUPLING_EXPORT DataArrayDouble *changeNbOfComponents(int newNbOfComp, double dftValue) const throw(INTERP_KERNEL::Exception);
MEDCOUPLING_EXPORT DataArrayDouble *keepSelectedComponents(const std::vector<int>& compoIds) const throw(INTERP_KERNEL::Exception);
MEDCOUPLING_EXPORT void meldWith(const DataArrayDouble *other) throw(INTERP_KERNEL::Exception);
MEDCOUPLING_EXPORT void setIJ(int tupleId, int compoId, double newVal) { _mem[tupleId*_info_on_compo.size()+compoId]=newVal; declareAsNew(); }
MEDCOUPLING_EXPORT void setIJSilent(int tupleId, int compoId, double newVal) { _mem[tupleId*_info_on_compo.size()+compoId]=newVal; }
MEDCOUPLING_EXPORT double *getPointer() const { return _mem.getPointer(); }
- MEDCOUPLING_EXPORT static void setArrayIn(DataArrayDouble *newArray, DataArrayDouble* &arrayToSet);
+ MEDCOUPLING_EXPORT static void SetArrayIn(DataArrayDouble *newArray, DataArrayDouble* &arrayToSet);
MEDCOUPLING_EXPORT const double *getConstPointer() const { return _mem.getConstPointer(); }
MEDCOUPLING_EXPORT void useArray(const double *array, bool ownership, DeallocType type, int nbOfTuple, int nbOfCompo);
MEDCOUPLING_EXPORT void writeOnPlace(int id, double element0, const double *others, int sizeOfOthers) { _mem.writeOnPlace(id,element0,others,sizeOfOthers); }
MEDCOUPLING_EXPORT void applyFuncFast32(const char *func) throw(INTERP_KERNEL::Exception);
MEDCOUPLING_EXPORT void applyFuncFast64(const char *func) throw(INTERP_KERNEL::Exception);
MEDCOUPLING_EXPORT DataArrayInt *getIdsInRange(double vmin, double vmax) const throw(INTERP_KERNEL::Exception);
- MEDCOUPLING_EXPORT static DataArrayDouble *aggregate(const DataArrayDouble *a1, const DataArrayDouble *a2) throw(INTERP_KERNEL::Exception);
- MEDCOUPLING_EXPORT static DataArrayDouble *aggregate(const std::vector<const DataArrayDouble *>& a) throw(INTERP_KERNEL::Exception);
- MEDCOUPLING_EXPORT static DataArrayDouble *meld(const DataArrayDouble *a1, const DataArrayDouble *a2) throw(INTERP_KERNEL::Exception);
- MEDCOUPLING_EXPORT static DataArrayDouble *meld(const std::vector<const DataArrayDouble *>& a) throw(INTERP_KERNEL::Exception);
- MEDCOUPLING_EXPORT static DataArrayDouble *dot(const DataArrayDouble *a1, const DataArrayDouble *a2) throw(INTERP_KERNEL::Exception);
- MEDCOUPLING_EXPORT static DataArrayDouble *crossProduct(const DataArrayDouble *a1, const DataArrayDouble *a2) throw(INTERP_KERNEL::Exception);
- MEDCOUPLING_EXPORT static DataArrayDouble *max(const DataArrayDouble *a1, const DataArrayDouble *a2) throw(INTERP_KERNEL::Exception);
- MEDCOUPLING_EXPORT static DataArrayDouble *min(const DataArrayDouble *a1, const DataArrayDouble *a2) throw(INTERP_KERNEL::Exception);
- MEDCOUPLING_EXPORT static DataArrayDouble *add(const DataArrayDouble *a1, const DataArrayDouble *a2) throw(INTERP_KERNEL::Exception);
+ MEDCOUPLING_EXPORT static DataArrayDouble *Aggregate(const DataArrayDouble *a1, const DataArrayDouble *a2) throw(INTERP_KERNEL::Exception);
+ MEDCOUPLING_EXPORT static DataArrayDouble *Aggregate(const std::vector<const DataArrayDouble *>& a) throw(INTERP_KERNEL::Exception);
+ MEDCOUPLING_EXPORT static DataArrayDouble *Meld(const DataArrayDouble *a1, const DataArrayDouble *a2) throw(INTERP_KERNEL::Exception);
+ MEDCOUPLING_EXPORT static DataArrayDouble *Meld(const std::vector<const DataArrayDouble *>& a) throw(INTERP_KERNEL::Exception);
+ MEDCOUPLING_EXPORT static DataArrayDouble *Dot(const DataArrayDouble *a1, const DataArrayDouble *a2) throw(INTERP_KERNEL::Exception);
+ MEDCOUPLING_EXPORT static DataArrayDouble *CrossProduct(const DataArrayDouble *a1, const DataArrayDouble *a2) throw(INTERP_KERNEL::Exception);
+ MEDCOUPLING_EXPORT static DataArrayDouble *Max(const DataArrayDouble *a1, const DataArrayDouble *a2) throw(INTERP_KERNEL::Exception);
+ MEDCOUPLING_EXPORT static DataArrayDouble *Min(const DataArrayDouble *a1, const DataArrayDouble *a2) throw(INTERP_KERNEL::Exception);
+ MEDCOUPLING_EXPORT static DataArrayDouble *Add(const DataArrayDouble *a1, const DataArrayDouble *a2) throw(INTERP_KERNEL::Exception);
MEDCOUPLING_EXPORT void addEqual(const DataArrayDouble *other) throw(INTERP_KERNEL::Exception);
- MEDCOUPLING_EXPORT static DataArrayDouble *substract(const DataArrayDouble *a1, const DataArrayDouble *a2) throw(INTERP_KERNEL::Exception);
+ MEDCOUPLING_EXPORT static DataArrayDouble *Substract(const DataArrayDouble *a1, const DataArrayDouble *a2) throw(INTERP_KERNEL::Exception);
MEDCOUPLING_EXPORT void substractEqual(const DataArrayDouble *other) throw(INTERP_KERNEL::Exception);
- MEDCOUPLING_EXPORT static DataArrayDouble *multiply(const DataArrayDouble *a1, const DataArrayDouble *a2) throw(INTERP_KERNEL::Exception);
+ MEDCOUPLING_EXPORT static DataArrayDouble *Multiply(const DataArrayDouble *a1, const DataArrayDouble *a2) throw(INTERP_KERNEL::Exception);
MEDCOUPLING_EXPORT void multiplyEqual(const DataArrayDouble *other) throw(INTERP_KERNEL::Exception);
- MEDCOUPLING_EXPORT static DataArrayDouble *divide(const DataArrayDouble *a1, const DataArrayDouble *a2) throw(INTERP_KERNEL::Exception);
+ MEDCOUPLING_EXPORT static DataArrayDouble *Divide(const DataArrayDouble *a1, const DataArrayDouble *a2) throw(INTERP_KERNEL::Exception);
MEDCOUPLING_EXPORT void divideEqual(const DataArrayDouble *other) throw(INTERP_KERNEL::Exception);
//! nothing to do here because this class does not aggregate any TimeLabel instance.
MEDCOUPLING_EXPORT void updateTime() { }
MEDCOUPLING_EXPORT void alloc(int nbOfTuple, int nbOfCompo);
MEDCOUPLING_EXPORT bool isEqual(const DataArrayInt& other) const;
MEDCOUPLING_EXPORT bool isEqualWithoutConsideringStr(const DataArrayInt& other) const;
+ MEDCOUPLING_EXPORT bool isEqualWithoutConsideringStrAndOrder(const DataArrayInt& other) const throw(INTERP_KERNEL::Exception);
+ MEDCOUPLING_EXPORT DataArrayInt *buildPermutationArr(const DataArrayInt& other) const throw(INTERP_KERNEL::Exception);
+ MEDCOUPLING_EXPORT void sort() throw(INTERP_KERNEL::Exception);
MEDCOUPLING_EXPORT void fillWithZero();
MEDCOUPLING_EXPORT void fillWithValue(int val);
MEDCOUPLING_EXPORT void iota(int init=0) throw(INTERP_KERNEL::Exception);
MEDCOUPLING_EXPORT bool isIdentity() const;
MEDCOUPLING_EXPORT bool isUniform(int val) const;
MEDCOUPLING_EXPORT DataArrayInt *substr(int tupleIdBg, int tupleIdEnd=-1) const throw(INTERP_KERNEL::Exception);
+ MEDCOUPLING_EXPORT void rearrange(int newNbOfCompo) throw(INTERP_KERNEL::Exception);
MEDCOUPLING_EXPORT DataArrayInt *changeNbOfComponents(int newNbOfComp, int dftValue) const throw(INTERP_KERNEL::Exception);
MEDCOUPLING_EXPORT DataArrayInt *keepSelectedComponents(const std::vector<int>& compoIds) const throw(INTERP_KERNEL::Exception);
MEDCOUPLING_EXPORT void meldWith(const DataArrayInt *other) throw(INTERP_KERNEL::Exception);
MEDCOUPLING_EXPORT void setIJ(int tupleId, int compoId, int newVal) { _mem[tupleId*_info_on_compo.size()+compoId]=newVal; declareAsNew(); }
MEDCOUPLING_EXPORT void setIJSilent(int tupleId, int compoId, int newVal) { _mem[tupleId*_info_on_compo.size()+compoId]=newVal; }
MEDCOUPLING_EXPORT int *getPointer() const { return _mem.getPointer(); }
- MEDCOUPLING_EXPORT static void setArrayIn(DataArrayInt *newArray, DataArrayInt* &arrayToSet);
+ MEDCOUPLING_EXPORT static void SetArrayIn(DataArrayInt *newArray, DataArrayInt* &arrayToSet);
MEDCOUPLING_EXPORT const int *getConstPointer() const { return _mem.getConstPointer(); }
MEDCOUPLING_EXPORT DataArrayInt *getIdsEqual(int val) const throw(INTERP_KERNEL::Exception);
MEDCOUPLING_EXPORT DataArrayInt *getIdsEqualList(const std::vector<int>& vals) const throw(INTERP_KERNEL::Exception);
MEDCOUPLING_EXPORT int getMaxValue(int& tupleId) const throw(INTERP_KERNEL::Exception);
MEDCOUPLING_EXPORT int getMinValue(int& tupleId) const throw(INTERP_KERNEL::Exception);
- MEDCOUPLING_EXPORT static DataArrayInt *aggregate(const DataArrayInt *a1, const DataArrayInt *a2, int offsetA2);
- MEDCOUPLING_EXPORT static DataArrayInt *meld(const DataArrayInt *a1, const DataArrayInt *a2) throw(INTERP_KERNEL::Exception);
- MEDCOUPLING_EXPORT static DataArrayInt *meld(const std::vector<const DataArrayInt *>& a) throw(INTERP_KERNEL::Exception);
- MEDCOUPLING_EXPORT static DataArrayInt *makePartition(const std::vector<DataArrayInt *>& groups, int newNb, std::vector< std::vector<int> >& fidsOfGroups);
+ MEDCOUPLING_EXPORT void applyLin(int a, int b, int compoId) throw(INTERP_KERNEL::Exception);
+ MEDCOUPLING_EXPORT static DataArrayInt *Aggregate(const DataArrayInt *a1, const DataArrayInt *a2, int offsetA2);
+ MEDCOUPLING_EXPORT static DataArrayInt *Aggregate(const std::vector<const DataArrayInt *>& a) throw(INTERP_KERNEL::Exception);
+ MEDCOUPLING_EXPORT static DataArrayInt *Meld(const DataArrayInt *a1, const DataArrayInt *a2) throw(INTERP_KERNEL::Exception);
+ MEDCOUPLING_EXPORT static DataArrayInt *Meld(const std::vector<const DataArrayInt *>& a) throw(INTERP_KERNEL::Exception);
+ MEDCOUPLING_EXPORT static DataArrayInt *MakePartition(const std::vector<const DataArrayInt *>& groups, int newNb, std::vector< std::vector<int> >& fidsOfGroups);
+ MEDCOUPLING_EXPORT static DataArrayInt *BuildUnion(const std::vector<const DataArrayInt *>& a) throw(INTERP_KERNEL::Exception);
+ MEDCOUPLING_EXPORT static DataArrayInt *BuildIntersection(const std::vector<const DataArrayInt *>& a) throw(INTERP_KERNEL::Exception);
MEDCOUPLING_EXPORT DataArrayInt *buildComplement(int nbOfElement) const throw(INTERP_KERNEL::Exception);
MEDCOUPLING_EXPORT DataArrayInt *buildSubstraction(const DataArrayInt *other) const throw(INTERP_KERNEL::Exception);
MEDCOUPLING_EXPORT DataArrayInt *buildUnion(const DataArrayInt *other) const throw(INTERP_KERNEL::Exception);
MEDCOUPLING_EXPORT DataArrayInt *buildIntersection(const DataArrayInt *other) const throw(INTERP_KERNEL::Exception);
MEDCOUPLING_EXPORT DataArrayInt *deltaShiftIndex() const throw(INTERP_KERNEL::Exception);
+ MEDCOUPLING_EXPORT std::set<int> getDifferentValues() const throw(INTERP_KERNEL::Exception);
MEDCOUPLING_EXPORT void useArray(const int *array, bool ownership, DeallocType type, int nbOfTuple, int nbOfCompo);
MEDCOUPLING_EXPORT void writeOnPlace(int id, int element0, const int *others, int sizeOfOthers) { _mem.writeOnPlace(id,element0,others,sizeOfOthers); }
//! nothing to do here because this class does not aggregate any TimeLabel instance.
MEDCOUPLING_EXPORT void updateTime() { }
public:
- MEDCOUPLING_EXPORT static int *checkAndPreparePermutation(const int *start, const int *end);
+ MEDCOUPLING_EXPORT static int *CheckAndPreparePermutation(const int *start, const int *end);
private:
DataArrayInt() { }
private:
return ret;
}
+ template<class T>
+ void MemArray<T>::sort()
+ {
+ T *pt=_pointer.getPointer();
+ std::sort(pt,pt+_nb_of_elem);
+ }
+
template<class T>
void MemArray<T>::alloc(int nbOfElements)
{
* retruns a newly created mesh with counter=1
* that is the union of mesh1 and mesh2 if possible. The cells of mesh2 will appear after cells of 'mesh1'. Idem for nodes.
*/
-MEDCouplingMesh *MEDCouplingMesh::mergeMeshes(const MEDCouplingMesh *mesh1, const MEDCouplingMesh *mesh2)
+MEDCouplingMesh *MEDCouplingMesh::MergeMeshes(const MEDCouplingMesh *mesh1, const MEDCouplingMesh *mesh2)
{
return mesh1->mergeMyselfWith(mesh2);
}
virtual MEDCouplingUMesh *buildUnstructured() const throw(INTERP_KERNEL::Exception) = 0;
virtual DataArrayInt *simplexize(int policy) throw(INTERP_KERNEL::Exception) = 0;
virtual bool areCompatibleForMerge(const MEDCouplingMesh *other) const;
- static MEDCouplingMesh *mergeMeshes(const MEDCouplingMesh *mesh1, const MEDCouplingMesh *mesh2);
+ static MEDCouplingMesh *MergeMeshes(const MEDCouplingMesh *mesh1, const MEDCouplingMesh *mesh2);
//serialisation-unserialization
virtual void getTinySerializationInformation(std::vector<int>& tinyInfo, std::vector<std::string>& littleStrings) const = 0;
virtual void resizeForUnserialization(const std::vector<int>& tinyInfo, DataArrayInt *a1, DataArrayDouble *a2, std::vector<std::string>& littleStrings) const = 0;
/*!
* merge _coords arrays of m1 and m2 and returns the union. The returned instance is newly created with ref count == 1.
*/
-DataArrayDouble *MEDCouplingPointSet::mergeNodesArray(const MEDCouplingPointSet *m1, const MEDCouplingPointSet *m2) throw(INTERP_KERNEL::Exception)
+DataArrayDouble *MEDCouplingPointSet::MergeNodesArray(const MEDCouplingPointSet *m1, const MEDCouplingPointSet *m2) throw(INTERP_KERNEL::Exception)
{
int spaceDim=m1->getSpaceDimension();
if(spaceDim!=m2->getSpaceDimension())
- throw INTERP_KERNEL::Exception("Mismatch in SpaceDim during call of mergeNodesArray !");
- return DataArrayDouble::aggregate(m1->getCoords(),m2->getCoords());
+ throw INTERP_KERNEL::Exception("Mismatch in SpaceDim during call of MergeNodesArray !");
+ return DataArrayDouble::Aggregate(m1->getCoords(),m2->getCoords());
}
-DataArrayDouble *MEDCouplingPointSet::mergeNodesArray(const std::vector<const MEDCouplingPointSet *>& ms) throw(INTERP_KERNEL::Exception)
+DataArrayDouble *MEDCouplingPointSet::MergeNodesArray(const std::vector<const MEDCouplingPointSet *>& ms) throw(INTERP_KERNEL::Exception)
{
if(ms.empty())
- throw INTERP_KERNEL::Exception("MEDCouplingPointSet::mergeNodesArray : input array must be NON EMPTY !");
+ throw INTERP_KERNEL::Exception("MEDCouplingPointSet::MergeNodesArray : input array must be NON EMPTY !");
std::vector<const MEDCouplingPointSet *>::const_iterator it=ms.begin();
std::vector<const DataArrayDouble *> coo(ms.size());
int spaceDim=(*it)->getSpaceDimension();
if((*it)->getSpaceDimension()==spaceDim)
coo[i]=tmp;
else
- throw INTERP_KERNEL::Exception("Mismatch in SpaceDim during call of mergeNodesArray !");
+ throw INTERP_KERNEL::Exception("Mismatch in SpaceDim during call of MergeNodesArray !");
}
else
- throw INTERP_KERNEL::Exception("Empty coords detected during call of mergeNodesArray !");
+ throw INTERP_KERNEL::Exception("Empty coords detected during call of MergeNodesArray !");
}
- return DataArrayDouble::aggregate(coo);
+ return DataArrayDouble::Aggregate(coo);
}
/*!
* Factory to build new instance of instanciable subclasses of MEDCouplingPointSet.
* This method is used during unserialization process.
*/
-MEDCouplingPointSet *MEDCouplingPointSet::buildInstanceFromMeshType(MEDCouplingMeshType type)
+MEDCouplingPointSet *MEDCouplingPointSet::BuildInstanceFromMeshType(MEDCouplingMeshType type)
{
switch(type)
{
{
double *coords=_coords->getPointer();
int nbNodes=getNumberOfNodes();
- rotate3DAlg(center,vect,angle,nbNodes,coords);
+ Rotate3DAlg(center,vect,angle,nbNodes,coords);
}
/*!
* Low static method that operates 3D rotation of 'nbNodes' 3D nodes whose coordinates are arranged in 'coords'
* around an axe ('center','vect') and with angle 'angle'.
*/
-void MEDCouplingPointSet::rotate3DAlg(const double *center, const double *vect, double angle, int nbNodes, double *coords)
+void MEDCouplingPointSet::Rotate3DAlg(const double *center, const double *vect, double angle, int nbNodes, double *coords)
{
double sina=sin(angle);
double cosa=cos(angle);
{
double *coords=_coords->getPointer();
int nbNodes=getNumberOfNodes();
- rotate2DAlg(center,angle,nbNodes,coords);
+ Rotate2DAlg(center,angle,nbNodes,coords);
}
/*!
* Low static method that operates 3D rotation of 'nbNodes' 3D nodes whose coordinates are arranged in 'coords'
* around the center point 'center' and with angle 'angle'.
*/
-void MEDCouplingPointSet::rotate2DAlg(const double *center, double angle, int nbNodes, double *coords)
+void MEDCouplingPointSet::Rotate2DAlg(const double *center, double angle, int nbNodes, double *coords)
{
double cosa=cos(angle);
double sina=sin(angle);
void tryToShareSameCoords(const MEDCouplingPointSet& other, double epsilon) throw(INTERP_KERNEL::Exception);
virtual void tryToShareSameCoordsPermute(const MEDCouplingPointSet& other, double epsilon) throw(INTERP_KERNEL::Exception) = 0;
void findNodesOnPlane(const double *pt, const double *vec, double eps, std::vector<int>& nodes) const throw(INTERP_KERNEL::Exception);
- static DataArrayDouble *mergeNodesArray(const MEDCouplingPointSet *m1, const MEDCouplingPointSet *m2) throw(INTERP_KERNEL::Exception);
- static DataArrayDouble *mergeNodesArray(const std::vector<const MEDCouplingPointSet *>& ms) throw(INTERP_KERNEL::Exception);
- static MEDCouplingPointSet *buildInstanceFromMeshType(MEDCouplingMeshType type);
- static void rotate2DAlg(const double *center, double angle, int nbNodes, double *coords);
- static void rotate3DAlg(const double *center, const double *vect, double angle, int nbNodes, double *coords);
+ static DataArrayDouble *MergeNodesArray(const MEDCouplingPointSet *m1, const MEDCouplingPointSet *m2) throw(INTERP_KERNEL::Exception);
+ static DataArrayDouble *MergeNodesArray(const std::vector<const MEDCouplingPointSet *>& ms) throw(INTERP_KERNEL::Exception);
+ static MEDCouplingPointSet *BuildInstanceFromMeshType(MEDCouplingMeshType type);
+ static void Rotate2DAlg(const double *center, double angle, int nbNodes, double *coords);
+ static void Rotate3DAlg(const double *center, const double *vect, double angle, int nbNodes, double *coords);
MEDCouplingMesh *buildPart(const int *start, const int *end) const;
MEDCouplingMesh *buildPartAndReduceNodes(const int *start, const int *end, DataArrayInt*& arr) const;
virtual MEDCouplingPointSet *buildPartOfMySelf(const int *start, const int *end, bool keepCoords) const = 0;
int nbCols2D=interpolation2D.interpolateMeshes(source_mesh_wrapper,target_mesh_wrapper,matrix2D,method);
MEDCouplingUMesh *s1D,*t1D;
double v[3];
- MEDCouplingExtrudedMesh::project1DMeshes(src_mesh->getMesh1D(),target_mesh->getMesh1D(),getPrecision(),s1D,t1D,v);
+ MEDCouplingExtrudedMesh::Project1DMeshes(src_mesh->getMesh1D(),target_mesh->getMesh1D(),getPrecision(),s1D,t1D,v);
MEDCouplingNormalizedUnstructuredMesh<1,1> s1DWrapper(s1D);
MEDCouplingNormalizedUnstructuredMesh<1,1> t1DWrapper(t1D);
std::vector<std::map<int,double> > matrix1D;
const MEDCouplingNoTimeLabel *otherC=dynamic_cast<const MEDCouplingNoTimeLabel *>(other);
if(!otherC)
throw INTERP_KERNEL::Exception("NoTimeLabel::aggregation on mismatched time discretization !");
- DataArrayDouble *arr=DataArrayDouble::aggregate(getArray(),other->getArray());
+ DataArrayDouble *arr=DataArrayDouble::Aggregate(getArray(),other->getArray());
MEDCouplingNoTimeLabel *ret=new MEDCouplingNoTimeLabel;
ret->setArray(arr,0);
arr->decrRef();
throw INTERP_KERNEL::Exception("NoTimeLabel::aggregate on mismatched time discretization !");
a[i]=itC->getArray();
}
- DataArrayDouble *arr=DataArrayDouble::aggregate(a);
+ DataArrayDouble *arr=DataArrayDouble::Aggregate(a);
MEDCouplingNoTimeLabel *ret=new MEDCouplingNoTimeLabel;
ret->setArray(arr,0);
arr->decrRef();
const MEDCouplingNoTimeLabel *otherC=dynamic_cast<const MEDCouplingNoTimeLabel *>(other);
if(!otherC)
throw INTERP_KERNEL::Exception("NoTimeLabel::meld on mismatched time discretization !");
- DataArrayDouble *arr=DataArrayDouble::meld(getArray(),other->getArray());
+ DataArrayDouble *arr=DataArrayDouble::Meld(getArray(),other->getArray());
MEDCouplingNoTimeLabel *ret=new MEDCouplingNoTimeLabel;
ret->setTimeTolerance(getTimeTolerance());
ret->setArray(arr,0);
const MEDCouplingNoTimeLabel *otherC=dynamic_cast<const MEDCouplingNoTimeLabel *>(other);
if(!otherC)
throw INTERP_KERNEL::Exception("NoTimeLabel::dot on mismatched time discretization !");
- DataArrayDouble *arr=DataArrayDouble::dot(getArray(),other->getArray());
+ DataArrayDouble *arr=DataArrayDouble::Dot(getArray(),other->getArray());
MEDCouplingNoTimeLabel *ret=new MEDCouplingNoTimeLabel;
ret->setArray(arr,0);
arr->decrRef();
const MEDCouplingNoTimeLabel *otherC=dynamic_cast<const MEDCouplingNoTimeLabel *>(other);
if(!otherC)
throw INTERP_KERNEL::Exception("NoTimeLabel::crossProduct on mismatched time discretization !");
- DataArrayDouble *arr=DataArrayDouble::crossProduct(getArray(),other->getArray());
+ DataArrayDouble *arr=DataArrayDouble::CrossProduct(getArray(),other->getArray());
MEDCouplingNoTimeLabel *ret=new MEDCouplingNoTimeLabel;
ret->setArray(arr,0);
arr->decrRef();
const MEDCouplingNoTimeLabel *otherC=dynamic_cast<const MEDCouplingNoTimeLabel *>(other);
if(!otherC)
throw INTERP_KERNEL::Exception("NoTimeLabel::max on mismatched time discretization !");
- DataArrayDouble *arr=DataArrayDouble::max(getArray(),other->getArray());
+ DataArrayDouble *arr=DataArrayDouble::Max(getArray(),other->getArray());
MEDCouplingNoTimeLabel *ret=new MEDCouplingNoTimeLabel;
ret->setArray(arr,0);
arr->decrRef();
const MEDCouplingNoTimeLabel *otherC=dynamic_cast<const MEDCouplingNoTimeLabel *>(other);
if(!otherC)
throw INTERP_KERNEL::Exception("NoTimeLabel::max on mismatched time discretization !");
- DataArrayDouble *arr=DataArrayDouble::min(getArray(),other->getArray());
+ DataArrayDouble *arr=DataArrayDouble::Min(getArray(),other->getArray());
MEDCouplingNoTimeLabel *ret=new MEDCouplingNoTimeLabel;
ret->setArray(arr,0);
arr->decrRef();
const MEDCouplingNoTimeLabel *otherC=dynamic_cast<const MEDCouplingNoTimeLabel *>(other);
if(!otherC)
throw INTERP_KERNEL::Exception("NoTimeLabel::add on mismatched time discretization !");
- DataArrayDouble *arr=DataArrayDouble::add(getArray(),other->getArray());
+ DataArrayDouble *arr=DataArrayDouble::Add(getArray(),other->getArray());
MEDCouplingNoTimeLabel *ret=new MEDCouplingNoTimeLabel;
ret->setArray(arr,0);
arr->decrRef();
const MEDCouplingNoTimeLabel *otherC=dynamic_cast<const MEDCouplingNoTimeLabel *>(other);
if(!otherC)
throw INTERP_KERNEL::Exception("NoTimeLabel::substract on mismatched time discretization !");
- DataArrayDouble *arr=DataArrayDouble::substract(getArray(),other->getArray());
+ DataArrayDouble *arr=DataArrayDouble::Substract(getArray(),other->getArray());
MEDCouplingNoTimeLabel *ret=new MEDCouplingNoTimeLabel;
ret->setArray(arr,0);
arr->decrRef();
const MEDCouplingNoTimeLabel *otherC=dynamic_cast<const MEDCouplingNoTimeLabel *>(other);
if(!otherC)
throw INTERP_KERNEL::Exception("NoTimeLabel::multiply on mismatched time discretization !");
- DataArrayDouble *arr=DataArrayDouble::multiply(getArray(),other->getArray());
+ DataArrayDouble *arr=DataArrayDouble::Multiply(getArray(),other->getArray());
MEDCouplingNoTimeLabel *ret=new MEDCouplingNoTimeLabel;
ret->setArray(arr,0);
arr->decrRef();
const MEDCouplingNoTimeLabel *otherC=dynamic_cast<const MEDCouplingNoTimeLabel *>(other);
if(!otherC)
throw INTERP_KERNEL::Exception("divide on mismatched time discretization !");
- DataArrayDouble *arr=DataArrayDouble::divide(getArray(),other->getArray());
+ DataArrayDouble *arr=DataArrayDouble::Divide(getArray(),other->getArray());
MEDCouplingNoTimeLabel *ret=new MEDCouplingNoTimeLabel;
ret->setArray(arr,0);
arr->decrRef();
throw INTERP_KERNEL::Exception(EXCEPTION_MSG);
}
+void MEDCouplingNoTimeLabel::setStartIteration(int it) throw(INTERP_KERNEL::Exception)
+{
+ throw INTERP_KERNEL::Exception(EXCEPTION_MSG);
+}
+
+void MEDCouplingNoTimeLabel::setEndIteration(int it) throw(INTERP_KERNEL::Exception)
+{
+ throw INTERP_KERNEL::Exception(EXCEPTION_MSG);
+}
+
+void MEDCouplingNoTimeLabel::setStartOrder(int order) throw(INTERP_KERNEL::Exception)
+{
+ throw INTERP_KERNEL::Exception(EXCEPTION_MSG);
+}
+
+void MEDCouplingNoTimeLabel::setEndOrder(int order) throw(INTERP_KERNEL::Exception)
+{
+ throw INTERP_KERNEL::Exception(EXCEPTION_MSG);
+}
+
+void MEDCouplingNoTimeLabel::setStartTimeValue(double time) throw(INTERP_KERNEL::Exception)
+{
+ throw INTERP_KERNEL::Exception(EXCEPTION_MSG);
+}
+
+void MEDCouplingNoTimeLabel::setEndTimeValue(double time) throw(INTERP_KERNEL::Exception)
+{
+ throw INTERP_KERNEL::Exception(EXCEPTION_MSG);
+}
+
void MEDCouplingNoTimeLabel::setStartTime(double time, int iteration, int order) throw(INTERP_KERNEL::Exception)
{
throw INTERP_KERNEL::Exception(EXCEPTION_MSG);
const MEDCouplingWithTimeStep *otherC=dynamic_cast<const MEDCouplingWithTimeStep *>(other);
if(!otherC)
throw INTERP_KERNEL::Exception("WithTimeStep::aggregation on mismatched time discretization !");
- DataArrayDouble *arr=DataArrayDouble::aggregate(getArray(),other->getArray());
+ DataArrayDouble *arr=DataArrayDouble::Aggregate(getArray(),other->getArray());
MEDCouplingWithTimeStep *ret=new MEDCouplingWithTimeStep;
ret->setArray(arr,0);
arr->decrRef();
throw INTERP_KERNEL::Exception("WithTimeStep::aggregate on mismatched time discretization !");
a[i]=itC->getArray();
}
- DataArrayDouble *arr=DataArrayDouble::aggregate(a);
+ DataArrayDouble *arr=DataArrayDouble::Aggregate(a);
MEDCouplingWithTimeStep *ret=new MEDCouplingWithTimeStep;
ret->setArray(arr,0);
arr->decrRef();
const MEDCouplingWithTimeStep *otherC=dynamic_cast<const MEDCouplingWithTimeStep *>(other);
if(!otherC)
throw INTERP_KERNEL::Exception("WithTimeStep::meld on mismatched time discretization !");
- DataArrayDouble *arr=DataArrayDouble::meld(getArray(),other->getArray());
+ DataArrayDouble *arr=DataArrayDouble::Meld(getArray(),other->getArray());
MEDCouplingWithTimeStep *ret=new MEDCouplingWithTimeStep;
ret->setArray(arr,0);
arr->decrRef();
if(!otherC)
throw INTERP_KERNEL::Exception("WithTimeStep::dot on mismatched time discretization !");
MEDCouplingWithTimeStep *ret=new MEDCouplingWithTimeStep;
- DataArrayDouble *arr=DataArrayDouble::dot(getArray(),other->getArray());
+ DataArrayDouble *arr=DataArrayDouble::Dot(getArray(),other->getArray());
ret->setArray(arr,0);
arr->decrRef();
return ret;
const MEDCouplingWithTimeStep *otherC=dynamic_cast<const MEDCouplingWithTimeStep *>(other);
if(!otherC)
throw INTERP_KERNEL::Exception("WithTimeStep::crossProduct on mismatched time discretization !");
- DataArrayDouble *arr=DataArrayDouble::crossProduct(getArray(),other->getArray());
+ DataArrayDouble *arr=DataArrayDouble::CrossProduct(getArray(),other->getArray());
MEDCouplingWithTimeStep *ret=new MEDCouplingWithTimeStep;
ret->setArray(arr,0);
arr->decrRef();
const MEDCouplingWithTimeStep *otherC=dynamic_cast<const MEDCouplingWithTimeStep *>(other);
if(!otherC)
throw INTERP_KERNEL::Exception("WithTimeStep::max on mismatched time discretization !");
- DataArrayDouble *arr=DataArrayDouble::max(getArray(),other->getArray());
+ DataArrayDouble *arr=DataArrayDouble::Max(getArray(),other->getArray());
MEDCouplingWithTimeStep *ret=new MEDCouplingWithTimeStep;
ret->setArray(arr,0);
arr->decrRef();
const MEDCouplingWithTimeStep *otherC=dynamic_cast<const MEDCouplingWithTimeStep *>(other);
if(!otherC)
throw INTERP_KERNEL::Exception("WithTimeStep::min on mismatched time discretization !");
- DataArrayDouble *arr=DataArrayDouble::min(getArray(),other->getArray());
+ DataArrayDouble *arr=DataArrayDouble::Min(getArray(),other->getArray());
MEDCouplingWithTimeStep *ret=new MEDCouplingWithTimeStep;
ret->setArray(arr,0);
arr->decrRef();
const MEDCouplingWithTimeStep *otherC=dynamic_cast<const MEDCouplingWithTimeStep *>(other);
if(!otherC)
throw INTERP_KERNEL::Exception("WithTimeStep::add on mismatched time discretization !");
- DataArrayDouble *arr=DataArrayDouble::add(getArray(),other->getArray());
+ DataArrayDouble *arr=DataArrayDouble::Add(getArray(),other->getArray());
MEDCouplingWithTimeStep *ret=new MEDCouplingWithTimeStep;
ret->setArray(arr,0);
arr->decrRef();
const MEDCouplingWithTimeStep *otherC=dynamic_cast<const MEDCouplingWithTimeStep *>(other);
if(!otherC)
throw INTERP_KERNEL::Exception("WithTimeStep::substract on mismatched time discretization !");
- DataArrayDouble *arr=DataArrayDouble::substract(getArray(),other->getArray());
+ DataArrayDouble *arr=DataArrayDouble::Substract(getArray(),other->getArray());
MEDCouplingWithTimeStep *ret=new MEDCouplingWithTimeStep;
ret->setArray(arr,0);
arr->decrRef();
const MEDCouplingWithTimeStep *otherC=dynamic_cast<const MEDCouplingWithTimeStep *>(other);
if(!otherC)
throw INTERP_KERNEL::Exception("WithTimeStep::multiply on mismatched time discretization !");
- DataArrayDouble *arr=DataArrayDouble::multiply(getArray(),other->getArray());
+ DataArrayDouble *arr=DataArrayDouble::Multiply(getArray(),other->getArray());
MEDCouplingWithTimeStep *ret=new MEDCouplingWithTimeStep;
ret->setArray(arr,0);
arr->decrRef();
const MEDCouplingWithTimeStep *otherC=dynamic_cast<const MEDCouplingWithTimeStep *>(other);
if(!otherC)
throw INTERP_KERNEL::Exception("WithTimeStep::divide on mismatched time discretization !");
- DataArrayDouble *arr=DataArrayDouble::divide(getArray(),other->getArray());
+ DataArrayDouble *arr=DataArrayDouble::Divide(getArray(),other->getArray());
MEDCouplingWithTimeStep *ret=new MEDCouplingWithTimeStep;
ret->setArray(arr,0);
arr->decrRef();
const MEDCouplingConstOnTimeInterval *otherC=dynamic_cast<const MEDCouplingConstOnTimeInterval *>(other);
if(!otherC)
throw INTERP_KERNEL::Exception("ConstOnTimeInterval::aggregation on mismatched time discretization !");
- DataArrayDouble *arr=DataArrayDouble::aggregate(getArray(),other->getArray());
+ DataArrayDouble *arr=DataArrayDouble::Aggregate(getArray(),other->getArray());
MEDCouplingConstOnTimeInterval *ret=new MEDCouplingConstOnTimeInterval;
ret->setArray(arr,0);
arr->decrRef();
throw INTERP_KERNEL::Exception("ConstOnTimeInterval::aggregate on mismatched time discretization !");
a[i]=itC->getArray();
}
- DataArrayDouble *arr=DataArrayDouble::aggregate(a);
+ DataArrayDouble *arr=DataArrayDouble::Aggregate(a);
MEDCouplingConstOnTimeInterval *ret=new MEDCouplingConstOnTimeInterval;
ret->setArray(arr,0);
arr->decrRef();
const MEDCouplingConstOnTimeInterval *otherC=dynamic_cast<const MEDCouplingConstOnTimeInterval *>(other);
if(!otherC)
throw INTERP_KERNEL::Exception("ConstOnTimeInterval::meld on mismatched time discretization !");
- DataArrayDouble *arr=DataArrayDouble::meld(getArray(),other->getArray());
+ DataArrayDouble *arr=DataArrayDouble::Meld(getArray(),other->getArray());
MEDCouplingConstOnTimeInterval *ret=new MEDCouplingConstOnTimeInterval;
ret->setTimeTolerance(getTimeTolerance());
ret->setArray(arr,0);
const MEDCouplingConstOnTimeInterval *otherC=dynamic_cast<const MEDCouplingConstOnTimeInterval *>(other);
if(!otherC)
throw INTERP_KERNEL::Exception("ConstOnTimeInterval::dot on mismatched time discretization !");
- DataArrayDouble *arr=DataArrayDouble::dot(getArray(),other->getArray());
+ DataArrayDouble *arr=DataArrayDouble::Dot(getArray(),other->getArray());
MEDCouplingConstOnTimeInterval *ret=new MEDCouplingConstOnTimeInterval;
ret->setArray(arr,0);
arr->decrRef();
const MEDCouplingConstOnTimeInterval *otherC=dynamic_cast<const MEDCouplingConstOnTimeInterval *>(other);
if(!otherC)
throw INTERP_KERNEL::Exception("ConstOnTimeInterval::crossProduct on mismatched time discretization !");
- DataArrayDouble *arr=DataArrayDouble::crossProduct(getArray(),other->getArray());
+ DataArrayDouble *arr=DataArrayDouble::CrossProduct(getArray(),other->getArray());
MEDCouplingConstOnTimeInterval *ret=new MEDCouplingConstOnTimeInterval;
ret->setArray(arr,0);
arr->decrRef();
const MEDCouplingConstOnTimeInterval *otherC=dynamic_cast<const MEDCouplingConstOnTimeInterval *>(other);
if(!otherC)
throw INTERP_KERNEL::Exception("ConstOnTimeInterval::max on mismatched time discretization !");
- DataArrayDouble *arr=DataArrayDouble::max(getArray(),other->getArray());
+ DataArrayDouble *arr=DataArrayDouble::Max(getArray(),other->getArray());
MEDCouplingConstOnTimeInterval *ret=new MEDCouplingConstOnTimeInterval;
ret->setArray(arr,0);
arr->decrRef();
const MEDCouplingConstOnTimeInterval *otherC=dynamic_cast<const MEDCouplingConstOnTimeInterval *>(other);
if(!otherC)
throw INTERP_KERNEL::Exception("ConstOnTimeInterval::min on mismatched time discretization !");
- DataArrayDouble *arr=DataArrayDouble::min(getArray(),other->getArray());
+ DataArrayDouble *arr=DataArrayDouble::Min(getArray(),other->getArray());
MEDCouplingConstOnTimeInterval *ret=new MEDCouplingConstOnTimeInterval;
ret->setArray(arr,0);
arr->decrRef();
const MEDCouplingConstOnTimeInterval *otherC=dynamic_cast<const MEDCouplingConstOnTimeInterval *>(other);
if(!otherC)
throw INTERP_KERNEL::Exception("ConstOnTimeInterval::add on mismatched time discretization !");
- DataArrayDouble *arr=DataArrayDouble::add(getArray(),other->getArray());
+ DataArrayDouble *arr=DataArrayDouble::Add(getArray(),other->getArray());
MEDCouplingConstOnTimeInterval *ret=new MEDCouplingConstOnTimeInterval;
ret->setArray(arr,0);
arr->decrRef();
const MEDCouplingConstOnTimeInterval *otherC=dynamic_cast<const MEDCouplingConstOnTimeInterval *>(other);
if(!otherC)
throw INTERP_KERNEL::Exception("ConstOnTimeInterval::substract on mismatched time discretization !");
- DataArrayDouble *arr=DataArrayDouble::substract(getArray(),other->getArray());
+ DataArrayDouble *arr=DataArrayDouble::Substract(getArray(),other->getArray());
MEDCouplingConstOnTimeInterval *ret=new MEDCouplingConstOnTimeInterval;
ret->setArray(arr,0);
arr->decrRef();
const MEDCouplingConstOnTimeInterval *otherC=dynamic_cast<const MEDCouplingConstOnTimeInterval *>(other);
if(!otherC)
throw INTERP_KERNEL::Exception("multiply on mismatched time discretization !");
- DataArrayDouble *arr=DataArrayDouble::multiply(getArray(),other->getArray());
+ DataArrayDouble *arr=DataArrayDouble::Multiply(getArray(),other->getArray());
MEDCouplingConstOnTimeInterval *ret=new MEDCouplingConstOnTimeInterval;
ret->setArray(arr,0);
arr->decrRef();
const MEDCouplingConstOnTimeInterval *otherC=dynamic_cast<const MEDCouplingConstOnTimeInterval *>(other);
if(!otherC)
throw INTERP_KERNEL::Exception("divide on mismatched time discretization !");
- DataArrayDouble *arr=DataArrayDouble::divide(getArray(),other->getArray());
+ DataArrayDouble *arr=DataArrayDouble::Divide(getArray(),other->getArray());
MEDCouplingConstOnTimeInterval *ret=new MEDCouplingConstOnTimeInterval;
ret->setArray(arr,0);
arr->decrRef();
const MEDCouplingLinearTime *otherC=dynamic_cast<const MEDCouplingLinearTime *>(other);
if(!otherC)
throw INTERP_KERNEL::Exception("LinearTime::aggregation on mismatched time discretization !");
- DataArrayDouble *arr1=DataArrayDouble::aggregate(getArray(),other->getArray());
- DataArrayDouble *arr2=DataArrayDouble::aggregate(getEndArray(),other->getEndArray());
+ DataArrayDouble *arr1=DataArrayDouble::Aggregate(getArray(),other->getArray());
+ DataArrayDouble *arr2=DataArrayDouble::Aggregate(getEndArray(),other->getEndArray());
MEDCouplingLinearTime *ret=new MEDCouplingLinearTime;
ret->setArray(arr1,0);
arr1->decrRef();
a[i]=itC->getArray();
b[i]=itC->getEndArray();
}
- DataArrayDouble *arr=DataArrayDouble::aggregate(a);
- DataArrayDouble *arr2=DataArrayDouble::aggregate(b);
+ DataArrayDouble *arr=DataArrayDouble::Aggregate(a);
+ DataArrayDouble *arr2=DataArrayDouble::Aggregate(b);
MEDCouplingLinearTime *ret=new MEDCouplingLinearTime;
ret->setArray(arr,0);
arr->decrRef();
const MEDCouplingLinearTime *otherC=dynamic_cast<const MEDCouplingLinearTime *>(other);
if(!otherC)
throw INTERP_KERNEL::Exception("LinearTime::meld on mismatched time discretization !");
- DataArrayDouble *arr1=DataArrayDouble::meld(getArray(),other->getArray());
- DataArrayDouble *arr2=DataArrayDouble::meld(getEndArray(),other->getEndArray());
+ DataArrayDouble *arr1=DataArrayDouble::Meld(getArray(),other->getArray());
+ DataArrayDouble *arr2=DataArrayDouble::Meld(getEndArray(),other->getEndArray());
MEDCouplingLinearTime *ret=new MEDCouplingLinearTime;
ret->setTimeTolerance(getTimeTolerance());
ret->setArray(arr1,0);
const MEDCouplingLinearTime *otherC=dynamic_cast<const MEDCouplingLinearTime *>(other);
if(!otherC)
throw INTERP_KERNEL::Exception("LinearTime::dot on mismatched time discretization !");
- DataArrayDouble *arr1=DataArrayDouble::dot(getArray(),other->getArray());
- DataArrayDouble *arr2=DataArrayDouble::dot(getEndArray(),other->getEndArray());
+ DataArrayDouble *arr1=DataArrayDouble::Dot(getArray(),other->getArray());
+ DataArrayDouble *arr2=DataArrayDouble::Dot(getEndArray(),other->getEndArray());
MEDCouplingLinearTime *ret=new MEDCouplingLinearTime;
ret->setArray(arr1,0);
arr1->decrRef();
const MEDCouplingLinearTime *otherC=dynamic_cast<const MEDCouplingLinearTime *>(other);
if(!otherC)
throw INTERP_KERNEL::Exception("LinearTime::crossProduct on mismatched time discretization !");
- DataArrayDouble *arr1=DataArrayDouble::crossProduct(getArray(),other->getArray());
- DataArrayDouble *arr2=DataArrayDouble::crossProduct(getEndArray(),other->getEndArray());
+ DataArrayDouble *arr1=DataArrayDouble::CrossProduct(getArray(),other->getArray());
+ DataArrayDouble *arr2=DataArrayDouble::CrossProduct(getEndArray(),other->getEndArray());
MEDCouplingLinearTime *ret=new MEDCouplingLinearTime;
ret->setArray(arr1,0);
arr1->decrRef();
if(!otherC)
throw INTERP_KERNEL::Exception("LinearTime::max on mismatched time discretization !");
MEDCouplingLinearTime *ret=new MEDCouplingLinearTime;
- DataArrayDouble *arr1=DataArrayDouble::max(getArray(),other->getArray());
+ DataArrayDouble *arr1=DataArrayDouble::Max(getArray(),other->getArray());
ret->setArray(arr1,0);
arr1->decrRef();
- DataArrayDouble *arr2=DataArrayDouble::max(getEndArray(),other->getEndArray());
+ DataArrayDouble *arr2=DataArrayDouble::Max(getEndArray(),other->getEndArray());
ret->setEndArray(arr2,0);
arr2->decrRef();
return ret;
const MEDCouplingLinearTime *otherC=dynamic_cast<const MEDCouplingLinearTime *>(other);
if(!otherC)
throw INTERP_KERNEL::Exception("LinearTime::min on mismatched time discretization !");
- DataArrayDouble *arr1=DataArrayDouble::min(getArray(),other->getArray());
- DataArrayDouble *arr2=DataArrayDouble::min(getEndArray(),other->getEndArray());
+ DataArrayDouble *arr1=DataArrayDouble::Min(getArray(),other->getArray());
+ DataArrayDouble *arr2=DataArrayDouble::Min(getEndArray(),other->getEndArray());
MEDCouplingLinearTime *ret=new MEDCouplingLinearTime;
ret->setArray(arr1,0);
arr1->decrRef();
const MEDCouplingLinearTime *otherC=dynamic_cast<const MEDCouplingLinearTime *>(other);
if(!otherC)
throw INTERP_KERNEL::Exception("LinearTime::add on mismatched time discretization !");
- DataArrayDouble *arr1=DataArrayDouble::add(getArray(),other->getArray());
- DataArrayDouble *arr2=DataArrayDouble::add(getEndArray(),other->getEndArray());
+ DataArrayDouble *arr1=DataArrayDouble::Add(getArray(),other->getArray());
+ DataArrayDouble *arr2=DataArrayDouble::Add(getEndArray(),other->getEndArray());
MEDCouplingLinearTime *ret=new MEDCouplingLinearTime;
ret->setArray(arr1,0);
arr1->decrRef();
const MEDCouplingLinearTime *otherC=dynamic_cast<const MEDCouplingLinearTime *>(other);
if(!otherC)
throw INTERP_KERNEL::Exception("LinearTime::substract on mismatched time discretization !");
- DataArrayDouble *arr1=DataArrayDouble::substract(getArray(),other->getArray());
- DataArrayDouble *arr2=DataArrayDouble::substract(getEndArray(),other->getEndArray());
+ DataArrayDouble *arr1=DataArrayDouble::Substract(getArray(),other->getArray());
+ DataArrayDouble *arr2=DataArrayDouble::Substract(getEndArray(),other->getEndArray());
MEDCouplingLinearTime *ret=new MEDCouplingLinearTime;
ret->setArray(arr1,0);
arr1->decrRef();
const MEDCouplingLinearTime *otherC=dynamic_cast<const MEDCouplingLinearTime *>(other);
if(!otherC)
throw INTERP_KERNEL::Exception("LinearTime::multiply on mismatched time discretization !");
- DataArrayDouble *arr1=DataArrayDouble::multiply(getArray(),other->getArray());
- DataArrayDouble *arr2=DataArrayDouble::multiply(getEndArray(),other->getEndArray());
+ DataArrayDouble *arr1=DataArrayDouble::Multiply(getArray(),other->getArray());
+ DataArrayDouble *arr2=DataArrayDouble::Multiply(getEndArray(),other->getEndArray());
MEDCouplingLinearTime *ret=new MEDCouplingLinearTime;
ret->setArray(arr1,0);
arr1->decrRef();
const MEDCouplingLinearTime *otherC=dynamic_cast<const MEDCouplingLinearTime *>(other);
if(!otherC)
throw INTERP_KERNEL::Exception("LinearTime::divide on mismatched time discretization !");
- DataArrayDouble *arr1=DataArrayDouble::divide(getArray(),other->getArray());
- DataArrayDouble *arr2=DataArrayDouble::divide(getEndArray(),other->getEndArray());
+ DataArrayDouble *arr1=DataArrayDouble::Divide(getArray(),other->getArray());
+ DataArrayDouble *arr2=DataArrayDouble::Divide(getEndArray(),other->getEndArray());
MEDCouplingLinearTime *ret=new MEDCouplingLinearTime;
ret->setArray(arr1,0);
arr1->decrRef();
virtual double getStartTime(int& iteration, int& order) const throw(INTERP_KERNEL::Exception) = 0;
virtual double getEndTime(int& iteration, int& order) const throw(INTERP_KERNEL::Exception) = 0;
void setTime(double time, int iteration, int order) throw(INTERP_KERNEL::Exception) { setStartTime(time,iteration,order); }
+ void setIteration(int it) throw(INTERP_KERNEL::Exception) { setStartIteration(it); }
+ void setOrder(int order) throw(INTERP_KERNEL::Exception) { setStartOrder(order); }
+ void setTimeValue(double val) throw(INTERP_KERNEL::Exception) { setStartTimeValue(val); }
+ virtual void setStartIteration(int it) throw(INTERP_KERNEL::Exception) = 0;
+ virtual void setEndIteration(int it) throw(INTERP_KERNEL::Exception) = 0;
+ virtual void setStartOrder(int order) throw(INTERP_KERNEL::Exception) = 0;
+ virtual void setEndOrder(int order) throw(INTERP_KERNEL::Exception) = 0;
+ virtual void setStartTimeValue(double time) throw(INTERP_KERNEL::Exception) = 0;
+ virtual void setEndTimeValue(double time) throw(INTERP_KERNEL::Exception) = 0;
virtual void setStartTime(double time, int iteration, int order) throw(INTERP_KERNEL::Exception) = 0;
virtual void setEndTime(double time, int iteration, int order) throw(INTERP_KERNEL::Exception) = 0;
virtual void getValueOnTime(int eltId, double time, double *value) const throw(INTERP_KERNEL::Exception) = 0;
bool isStrictlyBefore(const MEDCouplingTimeDiscretization *other) const throw(INTERP_KERNEL::Exception);
double getStartTime(int& iteration, int& order) const throw(INTERP_KERNEL::Exception);
double getEndTime(int& iteration, int& order) const throw(INTERP_KERNEL::Exception);
+ void setStartIteration(int it) throw(INTERP_KERNEL::Exception);
+ void setEndIteration(int it) throw(INTERP_KERNEL::Exception);
+ void setStartOrder(int order) throw(INTERP_KERNEL::Exception);
+ void setEndOrder(int order) throw(INTERP_KERNEL::Exception);
+ void setStartTimeValue(double time) throw(INTERP_KERNEL::Exception);
+ void setEndTimeValue(double time) throw(INTERP_KERNEL::Exception);
void setStartTime(double time, int iteration, int order) throw(INTERP_KERNEL::Exception);
void setEndTime(double time, int iteration, int order) throw(INTERP_KERNEL::Exception);
void getValueOnTime(int eltId, double time, double *value) const throw(INTERP_KERNEL::Exception);
void setEndTime(double time, int iteration, int order) throw(INTERP_KERNEL::Exception) { _time=time; _iteration=iteration; _order=order; }
double getStartTime(int& iteration, int& order) const throw(INTERP_KERNEL::Exception) { iteration=_iteration; order=_order; return _time; }
double getEndTime(int& iteration, int& order) const throw(INTERP_KERNEL::Exception) { iteration=_iteration; order=_order; return _time; }
+ void setStartIteration(int it) throw(INTERP_KERNEL::Exception) { _iteration=it; }
+ void setEndIteration(int it) throw(INTERP_KERNEL::Exception) { _iteration=it; }
+ void setStartOrder(int order) throw(INTERP_KERNEL::Exception) { _order=order; }
+ void setEndOrder(int order) throw(INTERP_KERNEL::Exception) { _order=order; }
+ void setStartTimeValue(double time) throw(INTERP_KERNEL::Exception) { _time=time; }
+ void setEndTimeValue(double time) throw(INTERP_KERNEL::Exception) { _time=time; }
std::vector< const DataArrayDouble *> getArraysForTime(double time) const throw(INTERP_KERNEL::Exception);
void getValueForTime(double time, const std::vector<double>& vals, double *res) const;
void getValueOnTime(int eltId, double time, double *value) const throw(INTERP_KERNEL::Exception);
void setEndTime(double time, int iteration, int order) throw(INTERP_KERNEL::Exception) { _end_time=time; _end_iteration=iteration; _end_order=order; }
double getStartTime(int& iteration, int& order) const throw(INTERP_KERNEL::Exception) { iteration=_start_iteration; order=_start_order; return _start_time; }
double getEndTime(int& iteration, int& order) const throw(INTERP_KERNEL::Exception) { iteration=_end_iteration; order=_end_order; return _end_time; }
+ void setStartIteration(int it) throw(INTERP_KERNEL::Exception) { _start_iteration=it; }
+ void setEndIteration(int it) throw(INTERP_KERNEL::Exception) { _end_iteration=it; }
+ void setStartOrder(int order) throw(INTERP_KERNEL::Exception) { _start_order=order; }
+ void setEndOrder(int order) throw(INTERP_KERNEL::Exception) { _end_order=order; }
+ void setStartTimeValue(double time) throw(INTERP_KERNEL::Exception) { _start_time=time; }
+ void setEndTimeValue(double time) throw(INTERP_KERNEL::Exception) { _end_time=time; }
void checkNoTimePresence() const throw(INTERP_KERNEL::Exception);
void checkTimePresence(double time) const throw(INTERP_KERNEL::Exception);
public:
void setEndTime(double time, int iteration, int order) throw(INTERP_KERNEL::Exception) { _end_time=time; _end_iteration=iteration; _end_order=order; }
double getStartTime(int& iteration, int& order) const throw(INTERP_KERNEL::Exception) { iteration=_start_iteration; order=_start_order; return _start_time; }
double getEndTime(int& iteration, int& order) const throw(INTERP_KERNEL::Exception) { iteration=_end_iteration; order=_end_order; return _end_time; }
+ void setStartIteration(int it) throw(INTERP_KERNEL::Exception) { _start_iteration=it; }
+ void setEndIteration(int it) throw(INTERP_KERNEL::Exception) { _end_iteration=it; }
+ void setStartOrder(int order) throw(INTERP_KERNEL::Exception) { _start_order=order; }
+ void setEndOrder(int order) throw(INTERP_KERNEL::Exception) { _end_order=order; }
+ void setStartTimeValue(double time) throw(INTERP_KERNEL::Exception) { _start_time=time; }
+ void setEndTimeValue(double time) throw(INTERP_KERNEL::Exception) { _end_time=time; }
void getTinySerializationIntInformation(std::vector<int>& tinyInfo) const;
void getTinySerializationDbleInformation(std::vector<double>& tinyInfo) const;
void getTinySerializationStrInformation(std::vector<std::string>& tinyInfo) const;
#include "InterpKernelGeo2DEdgeArcCircle.hxx"
#include "MEDCouplingAutoRefCountObjectPtr.hxx"
+
#include <sstream>
#include <numeric>
#include <cstring>
throw INTERP_KERNEL::Exception("Nodal connectivity index array is expected to be with number of components set to one !");
if(_nodal_connec_index->getInfoOnComponent(0)!="")
throw INTERP_KERNEL::Exception("Nodal connectivity index array is expected to have no info on its single component !");
+ int curNbOfCell=getNumberOfCells();
+ const int *curCI=_nodal_connec_index->getConstPointer();
+ for (int i=0; i<curNbOfCell; i++)
+ if(curCI[i+1]<curCI[i])
+ {
+ std::ostringstream oss;
+ oss<<"pb in connectivity index --> cell "<<i<<" conn_index[i]=" <<curCI[i]<<" conn_index[i+1]="<<curCI[i+1];
+ throw INTERP_KERNEL::Exception(oss.str().c_str());
+ }
}
}
void MEDCouplingUMesh::insertNextCell(INTERP_KERNEL::NormalizedCellType type, int size, const int *nodalConnOfCell) throw(INTERP_KERNEL::Exception)
{
const INTERP_KERNEL::CellModel& cm=INTERP_KERNEL::CellModel::getCellModel(type);
+ if(_nodal_connec_index==0)
+ throw INTERP_KERNEL::Exception("MEDCouplingUMesh::insertNextCell : nodal connectivity not set ! invoke allocateCells before calling insertNextCell !");
if((int)cm.getDimension()==_mesh_dim)
{
+ int nbOfElems=_nodal_connec_index->getNbOfElems()-1;
+ if(_iterator>=nbOfElems)
+ throw INTERP_KERNEL::Exception("MEDCouplingUMesh::insertNextCell : allocation of cells was wide enough ! Call insertNextCell with higher value or call finishInsertingCells !");
int *pt=_nodal_connec_index->getPointer();
int idx=pt[_iterator];
MEDCouplingMesh::checkFastEquivalWith(other,prec);
if(_types!=otherC->_types)
throw INTERP_KERNEL::Exception("checkDeepEquivalWith : Types are not equal !");
- MEDCouplingAutoRefCountObjectPtr<MEDCouplingUMesh> m=mergeUMeshes(this,otherC);
+ MEDCouplingAutoRefCountObjectPtr<MEDCouplingUMesh> m=MergeUMeshes(this,otherC);
bool areNodesMerged;
int newNbOfNodes;
int oldNbOfNodes=getNumberOfNodes();
throw INTERP_KERNEL::Exception("checkDeepEquivalOnSameNodesWith : Types are not equal !");
if(_coords!=otherC->_coords)
throw INTERP_KERNEL::Exception("checkDeepEquivalOnSameNodesWith : meshes do not share the same coordinates ! Use tryToShareSameCoordinates or call checkDeepEquivalWith !");
- std::vector<MEDCouplingUMesh *> ms(2);
- ms[0]=const_cast<MEDCouplingUMesh *>(this);
- ms[1]=const_cast<MEDCouplingUMesh *>(otherC);
- MEDCouplingAutoRefCountObjectPtr<MEDCouplingUMesh> m=mergeUMeshesOnSameCoords(ms);
+ std::vector<const MEDCouplingUMesh *> ms(2);
+ ms[0]=this;
+ ms[1]=otherC;
+ MEDCouplingAutoRefCountObjectPtr<MEDCouplingUMesh> m=MergeUMeshesOnSameCoords(ms);
MEDCouplingAutoRefCountObjectPtr<DataArrayInt> da=m->zipConnectivityTraducer(cellCompPol);
int maxId=*std::max_element(da->getConstPointer(),da->getConstPointer()+getNumberOfCells());
const int *pt=std::find_if(da->getConstPointer()+getNumberOfCells(),da->getConstPointer()+da->getNbOfElems(),std::bind2nd(std::greater<int>(),maxId));
*/
bool MEDCouplingUMesh::areCellsIncludedIn(const MEDCouplingUMesh *other, int compType, DataArrayInt *& arr) const throw(INTERP_KERNEL::Exception)
{
- MEDCouplingAutoRefCountObjectPtr<MEDCouplingUMesh> mesh=mergeUMeshesOnSameCoords(this,other);
+ MEDCouplingAutoRefCountObjectPtr<MEDCouplingUMesh> mesh=MergeUMeshesOnSameCoords(this,other);
MEDCouplingAutoRefCountObjectPtr<DataArrayInt> o2n=mesh->zipConnectivityTraducer(compType);
int nbOfCells=getNumberOfCells();
arr=o2n->substr(nbOfCells);
+ arr->setName(other->getName());
int tmp;
+ if(other->getNumberOfCells()==0)
+ return true;
return arr->getMaxValue(tmp)<nbOfCells;
}
/*!
* This method tries to use 'other' coords and use it for 'this'. If no exception was thrown after the call of this method :
- * this->_coords==other->_coords. If not a exception is thrown this remains unchanged.
+ * this->_coords==other->_coords. If an exception is thrown 'this' remains unchanged.
+ * Contrary to MEDCouplingUMesh::tryToShareSameCoords method this method makes a deeper analyze of coordinates (and so more expensive) than simple equality.
+ * Two nodes one in 'this' and other in 'other' are considered equal if the distance between the two is lower than epsilon.
*/
void MEDCouplingUMesh::tryToShareSameCoordsPermute(const MEDCouplingPointSet& other, double epsilon) throw(INTERP_KERNEL::Exception)
{
if(!_coords)
throw INTERP_KERNEL::Exception("tryToShareSameCoordsPermute : No coords specified in this whereas there is any in other !");
int otherNbOfNodes=other.getNumberOfNodes();
- MEDCouplingAutoRefCountObjectPtr<DataArrayDouble> newCoords=mergeNodesArray(&other,this);
+ MEDCouplingAutoRefCountObjectPtr<DataArrayDouble> newCoords=MergeNodesArray(&other,this);
_coords->incrRef();
MEDCouplingAutoRefCountObjectPtr<DataArrayDouble> oldCoords=_coords;
setCoords(newCoords);
int nbCells=getNumberOfCells();
const int *array=old2NewBg;
if(check)
- array=DataArrayInt::checkAndPreparePermutation(old2NewBg,old2NewBg+nbCells);
+ array=DataArrayInt::CheckAndPreparePermutation(old2NewBg,old2NewBg+nbCells);
//
const int *conn=_nodal_connec->getConstPointer();
const int *connI=_nodal_connec_index->getConstPointer();
return std::count_if(pt+ptI[cellId]+1,pt+ptI[cellId+1],std::bind2nd(std::not_equal_to<int>(),-1));
}
+/*!
+ * This method is equivalent to MEDCouplingUMesh::getAllTypes excecpt that it returns only types of submesh which cell ids are in [begin,end).
+ * This method avoids to compute explicitely submesh to get its types.
+ */
+std::set<INTERP_KERNEL::NormalizedCellType> MEDCouplingUMesh::getTypesOfPart(const int *begin, const int *end) const throw(INTERP_KERNEL::Exception)
+{
+ checkFullyDefined();
+ std::set<INTERP_KERNEL::NormalizedCellType> ret;
+ const int *conn=_nodal_connec->getConstPointer();
+ const int *connIndex=_nodal_connec_index->getConstPointer();
+ for(const int *w=begin;w!=end;w++)
+ ret.insert((INTERP_KERNEL::NormalizedCellType)conn[connIndex[*w]]);
+ return ret;
+}
+
/*!
* Method reserved for advanced users having prepared their connectivity before.
* Arrays 'conn' and 'connIndex' will be aggregated without any copy and their counter will be incremented.
*/
void MEDCouplingUMesh::setConnectivity(DataArrayInt *conn, DataArrayInt *connIndex, bool isComputingTypes)
{
- DataArrayInt::setArrayIn(conn,_nodal_connec);
- DataArrayInt::setArrayIn(connIndex,_nodal_connec_index);
+ DataArrayInt::SetArrayIn(conn,_nodal_connec);
+ DataArrayInt::SetArrayIn(connIndex,_nodal_connec_index);
if(isComputingTypes)
computeTypes();
declareAsNew();
return field;
}
+/*!
+ * This method is equivalent to MEDCouplingUMesh::getMeasureField except that only part defined by [begin,end) is returned !
+ * This method avoids to build explicitely part of this to perform the work.
+ */
+MEDCouplingFieldDouble *MEDCouplingUMesh::getPartMeasureField(bool isAbs, const int *begin, const int *end) const
+{
+ std::string name="PartMeasureOfMesh_";
+ name+=getName();
+ int nbelem=std::distance(begin,end);
+ MEDCouplingFieldDouble *field=MEDCouplingFieldDouble::New(ON_CELLS);
+ field->setName(name.c_str());
+ DataArrayDouble* array=DataArrayDouble::New();
+ array->alloc(nbelem,1);
+ double *area_vol=array->getPointer();
+ field->setArray(array) ;
+ array->decrRef();
+ field->setMesh(const_cast<MEDCouplingUMesh *>(this));
+ if(getMeshDimension()!=-1)
+ {
+ int ipt;
+ INTERP_KERNEL::NormalizedCellType type;
+ int dim_space=getSpaceDimension();
+ const double *coords=getCoords()->getConstPointer();
+ const int *connec=getNodalConnectivity()->getConstPointer();
+ const int *connec_index=getNodalConnectivityIndex()->getConstPointer();
+ for(const int *iel=begin;iel!=end;iel++)
+ {
+ ipt=connec_index[*iel];
+ type=(INTERP_KERNEL::NormalizedCellType)connec[ipt];
+ *area_vol++=INTERP_KERNEL::computeVolSurfOfCell2<int,INTERP_KERNEL::ALL_C_MODE>(type,connec+ipt+1,connec_index[*iel+1]-ipt-1,coords,dim_space);
+ }
+ if(isAbs)
+ std::transform(array->getPointer(),area_vol,array->getPointer(),std::ptr_fun<double,double>(fabs));
+ }
+ else
+ {
+ area_vol[0]=std::numeric_limits<double>::max();
+ }
+ return field;
+}
+
/*!
* This methods returns a field on nodes and no time. This method is usefull to check "P1*" conservative interpolators.
* This field returns the getMeasureField of the dualMesh in P1 sens of 'this'.
return ret;
}
+/*!
+ * This method is equivalent to MEDCouplingUMesh::buildOrthogonalField except that only part defined by [begin,end) is returned !
+ * This method avoids to build explicitely part of this to perform the work.
+ */
+MEDCouplingFieldDouble *MEDCouplingUMesh::buildPartOrthogonalField(const int *begin, const int *end) const
+{
+ if((getMeshDimension()!=2) && (getMeshDimension()!=1 || getSpaceDimension()!=2))
+ throw INTERP_KERNEL::Exception("Expected a umesh with ( meshDim == 2 spaceDim == 2 or 3 ) or ( meshDim == 1 spaceDim == 2 ) !");
+ MEDCouplingFieldDouble *ret=MEDCouplingFieldDouble::New(ON_CELLS,NO_TIME);
+ DataArrayDouble *array=DataArrayDouble::New();
+ int nbelems=std::distance(begin,end);
+ int nbComp=getMeshDimension()+1;
+ array->alloc(nbelems,nbComp);
+ double *vals=array->getPointer();
+ const int *connI=_nodal_connec_index->getConstPointer();
+ const int *conn=_nodal_connec->getConstPointer();
+ const double *coords=_coords->getConstPointer();
+ if(getMeshDimension()==2)
+ {
+ if(getSpaceDimension()==3)
+ {
+ DataArrayDouble *loc=getPartBarycenterAndOwner(begin,end);
+ const double *locPtr=loc->getConstPointer();
+ for(const int *i=begin;i!=end;i++,vals+=3,locPtr+=3)
+ {
+ int offset=connI[*i];
+ INTERP_KERNEL::crossprod<3>(locPtr,coords+3*conn[offset+1],coords+3*conn[offset+2],vals);
+ double n=INTERP_KERNEL::norm<3>(vals);
+ std::transform(vals,vals+3,vals,std::bind2nd(std::multiplies<double>(),1./n));
+ }
+ loc->decrRef();
+ }
+ else
+ {
+ for(int i=0;i<nbelems;i++)
+ { vals[3*i]=0.; vals[3*i+1]=0.; vals[3*i+2]=1.; }
+ }
+ }
+ else//meshdimension==1
+ {
+ double tmp[2];
+ for(const int *i=begin;i!=end;i++)
+ {
+ int offset=connI[*i];
+ std::transform(coords+2*conn[offset+2],coords+2*conn[offset+2]+2,coords+2*conn[offset+1],tmp,std::minus<double>());
+ double n=INTERP_KERNEL::norm<2>(tmp);
+ std::transform(tmp,tmp+2,tmp,std::bind2nd(std::multiplies<double>(),1./n));
+ *vals++=-tmp[1];
+ *vals++=tmp[0];
+ }
+ }
+ ret->setArray(array);
+ array->decrRef();
+ ret->setMesh(this);
+ return ret;
+}
+
/*!
* This methods returns a vector newly created field on cells that represents the direction vector of each 1D cell of this.
* This method is only callable on mesh with meshdim == 1 containing only SEG2.
* \b 1 for translation and rotation around point of 'mesh1D'.
* @return an unstructured mesh with meshDim==3 and spaceDim==3. The returned mesh has the same coords than 'this'.
*/
-MEDCouplingUMesh *MEDCouplingUMesh::buildExtrudedMeshFromThis(const MEDCouplingUMesh *mesh1D, int policy)
+MEDCouplingUMesh *MEDCouplingUMesh::buildExtrudedMesh(const MEDCouplingUMesh *mesh1D, int policy)
{
checkFullyDefined();
mesh1D->checkFullyDefined();
if(!mesh1D->isContiguous1D())
- throw INTERP_KERNEL::Exception("buildExtrudedMeshFromThis : 1D mesh passed in parameter is not contiguous !");
+ throw INTERP_KERNEL::Exception("buildExtrudedMesh : 1D mesh passed in parameter is not contiguous !");
if(getSpaceDimension()!=mesh1D->getSpaceDimension())
- throw INTERP_KERNEL::Exception("Invalid call to buildExtrudedMeshFromThis this and mesh1D must have same dimension !");
+ throw INTERP_KERNEL::Exception("Invalid call to buildExtrudedMesh this and mesh1D must have same dimension !");
if((getMeshDimension()!=2 || getSpaceDimension()!=3) && (getMeshDimension()!=1 || getSpaceDimension()!=2))
- throw INTERP_KERNEL::Exception("Invalid 'this' for buildExtrudedMeshFromThis method : must be (meshDim==2 and spaceDim==3) or (meshDim==1 and spaceDim==2) !");
+ throw INTERP_KERNEL::Exception("Invalid 'this' for buildExtrudedMesh method : must be (meshDim==2 and spaceDim==3) or (meshDim==1 and spaceDim==2) !");
if(mesh1D->getMeshDimension()!=1)
- throw INTERP_KERNEL::Exception("Invalid 'mesh1D' for buildExtrudedMeshFromThis method : must be meshDim==1 !");
+ throw INTERP_KERNEL::Exception("Invalid 'mesh1D' for buildExtrudedMesh method : must be meshDim==1 !");
bool isQuad=false;
if(isPresenceOfQuadratic())
{
}
/*!
- * This method incarnates the policy 0 for MEDCouplingUMesh::buildExtrudedMeshFromThis method.
+ * This method incarnates the policy 0 for MEDCouplingUMesh::buildExtrudedMesh method.
* @param mesh1D is the input 1D mesh used for translation computation.
* @return newCoords new coords filled by this method.
*/
}
/*!
- * This method incarnates the policy 1 for MEDCouplingUMesh::buildExtrudedMeshFromThis method.
+ * This method incarnates the policy 1 for MEDCouplingUMesh::buildExtrudedMesh method.
* @param mesh1D is the input 1D mesh used for translation and automatic rotation computation.
* @return newCoords new coords filled by this method.
*/
}
/*!
- * This method incarnates the policy 1 for MEDCouplingUMesh::buildExtrudedMeshFromThis method.
+ * This method incarnates the policy 1 for MEDCouplingUMesh::buildExtrudedMesh method.
* @param mesh1D is the input 1D mesh used for translation and automatic rotation computation.
* @return newCoords new coords filled by this method.
*/
}
/*!
- * This method incarnates the policy 1 for MEDCouplingUMesh::buildExtrudedMeshFromThis method.
+ * This method incarnates the policy 1 for MEDCouplingUMesh::buildExtrudedMesh method.
* @param mesh1D is the input 1D mesh used for translation and automatic rotation computation.
* @return newCoords new coords filled by this method.
*/
/*!
* This method is private because not easy to use for end user. This method is const contrary to
- * MEDCouplingUMesh::buildExtrudedMeshFromThis method because this->_coords are expected to contain
+ * MEDCouplingUMesh::buildExtrudedMesh method because this->_coords are expected to contain
* the coords sorted slice by slice.
* @param isQuad specifies presence of quadratic cells.
*/
INTERP_KERNEL::NormalizedCellType type=(INTERP_KERNEL::NormalizedCellType)conn[connI[i]];
if(!polyOnly || type==INTERP_KERNEL::NORM_POLYGON)
{
- if(!isPolygonWellOriented(vec,conn+connI[i]+1,conn+connI[i+1],coordsPtr))
+ if(!IsPolygonWellOriented(vec,conn+connI[i]+1,conn+connI[i+1],coordsPtr))
cells.push_back(i);
}
}
{
INTERP_KERNEL::NormalizedCellType type=(INTERP_KERNEL::NormalizedCellType)conn[connI[i]];
if(!polyOnly || type==INTERP_KERNEL::NORM_POLYGON)
- if(!isPolygonWellOriented(vec,conn+connI[i]+1,conn+connI[i+1],coordsPtr))
+ if(!IsPolygonWellOriented(vec,conn+connI[i]+1,conn+connI[i+1],coordsPtr))
{
isModified=true;
std::vector<int> tmp(connI[i+1]-connI[i]-2);
INTERP_KERNEL::NormalizedCellType type=(INTERP_KERNEL::NormalizedCellType)conn[connI[i]];
if(type==INTERP_KERNEL::NORM_POLYHED)
{
- if(!isPolyhedronWellOriented(conn+connI[i]+1,conn+connI[i+1],coordsPtr))
+ if(!IsPolyhedronWellOriented(conn+connI[i]+1,conn+connI[i+1],coordsPtr))
cells.push_back(i);
}
}
{
INTERP_KERNEL::NormalizedCellType type=(INTERP_KERNEL::NormalizedCellType)conn[connI[i]];
if(type==INTERP_KERNEL::NORM_POLYHED)
- if(!isPolyhedronWellOriented(conn+connI[i]+1,conn+connI[i+1],coordsPtr))
+ if(!IsPolyhedronWellOriented(conn+connI[i]+1,conn+connI[i+1],coordsPtr))
{
- tryToCorrectPolyhedronOrientation(conn+connI[i]+1,conn+connI[i+1],coordsPtr);
+ TryToCorrectPolyhedronOrientation(conn+connI[i]+1,conn+connI[i+1],coordsPtr);
isModified=true;
}
}
return ret;
}
+/*!
+ * This method returns a newly created DataArrayInt instance.
+ * This method retrieves cell ids in [begin,end) that have the type 'type'.
+ */
+DataArrayInt *MEDCouplingUMesh::keepCellIdsByType(INTERP_KERNEL::NormalizedCellType type, const int *begin, const int *end) const throw(INTERP_KERNEL::Exception)
+{
+ checkFullyDefined();
+ std::vector<int> r;
+ const int *conn=_nodal_connec->getConstPointer();
+ const int *connIndex=_nodal_connec_index->getConstPointer();
+ for(const int *w=begin;w!=end;w++)
+ if((INTERP_KERNEL::NormalizedCellType)conn[connIndex[*w]]==type)
+ r.push_back(*w);
+ DataArrayInt *ret=DataArrayInt::New();
+ ret->alloc(r.size(),1);
+ std::copy(r.begin(),r.end(),ret->getPointer());
+ return ret;
+}
+
/*!
* This method makes the assumption that da->getNumberOfTuples()<this->getNumberOfCells(). This method makes the assumption that ids contained in 'da'
* are in [0:getNumberOfCells())
if(other->getType()!=UNSTRUCTURED)
throw INTERP_KERNEL::Exception("Merge of umesh only available with umesh each other !");
const MEDCouplingUMesh *otherC=static_cast<const MEDCouplingUMesh *>(other);
- return mergeUMeshes(this,otherC);
+ return MergeUMeshes(this,otherC);
}
/*!
return ret;
}
+/*!
+ * This method is similar to MEDCouplingUMesh::getBarycenterAndOwner except that it works on subPart of 'this' without
+ * building explicitely it. The input part is defined by an array [begin,end). All ids contained in this array should be less than this->getNumberOfCells().
+ * No check of that will be done !
+ */
+DataArrayDouble *MEDCouplingUMesh::getPartBarycenterAndOwner(const int *begin, const int *end) const
+{
+ DataArrayDouble *ret=DataArrayDouble::New();
+ int spaceDim=getSpaceDimension();
+ int nbOfTuple=std::distance(begin,end);
+ ret->alloc(nbOfTuple,spaceDim);
+ double *ptToFill=ret->getPointer();
+ double *tmp=new double[spaceDim];
+ const int *nodal=_nodal_connec->getConstPointer();
+ const int *nodalI=_nodal_connec_index->getConstPointer();
+ const double *coor=_coords->getConstPointer();
+ for(const int *w=begin;w!=end;w++)
+ {
+ INTERP_KERNEL::NormalizedCellType type=(INTERP_KERNEL::NormalizedCellType)nodal[nodalI[*w]];
+ INTERP_KERNEL::computeBarycenter2<int,INTERP_KERNEL::ALL_C_MODE>(type,nodal+nodalI[*w]+1,nodalI[*w+1]-nodalI[*w]-1,coor,spaceDim,ptToFill);
+ ptToFill+=spaceDim;
+ }
+ delete [] tmp;
+ return ret;
+}
+
/*!
* Returns a newly created mesh (with ref count ==1) that contains merge of 'mesh1' and 'other'.
* The coords of 'mesh2' are added at the end of coords of 'mesh1'.
*/
-MEDCouplingUMesh *MEDCouplingUMesh::mergeUMeshes(const MEDCouplingUMesh *mesh1, const MEDCouplingUMesh *mesh2) throw(INTERP_KERNEL::Exception)
+MEDCouplingUMesh *MEDCouplingUMesh::MergeUMeshes(const MEDCouplingUMesh *mesh1, const MEDCouplingUMesh *mesh2) throw(INTERP_KERNEL::Exception)
{
std::vector<const MEDCouplingUMesh *> tmp(2);
tmp[0]=const_cast<MEDCouplingUMesh *>(mesh1); tmp[1]=const_cast<MEDCouplingUMesh *>(mesh2);
- return mergeUMeshes(tmp);
+ return MergeUMeshes(tmp);
}
-MEDCouplingUMesh *MEDCouplingUMesh::mergeUMeshes(std::vector<const MEDCouplingUMesh *>& a) throw(INTERP_KERNEL::Exception)
+MEDCouplingUMesh *MEDCouplingUMesh::MergeUMeshes(std::vector<const MEDCouplingUMesh *>& a) throw(INTERP_KERNEL::Exception)
{
if(a.empty())
- throw INTERP_KERNEL::Exception("MEDCouplingUMesh::mergeUMeshes : input array must be NON EMPTY !");
+ throw INTERP_KERNEL::Exception("MEDCouplingUMesh::MergeUMeshes : input array must be NON EMPTY !");
std::vector<const MEDCouplingUMesh *>::const_iterator it=a.begin();
int meshDim=(*it)->getMeshDimension();
int nbOfCells=(*it)->getNumberOfCells();
for(;it!=a.end();it++)
{
if(meshDim!=(*it)->getMeshDimension())
- throw INTERP_KERNEL::Exception("Mesh dimensions mismatches, mergeMeshes impossible !");
+ throw INTERP_KERNEL::Exception("Mesh dimensions mismatches, MergeUMeshes impossible !");
nbOfCells+=(*it)->getNumberOfCells();
meshLgth+=(*it)->getMeshLength();
}
std::vector<const MEDCouplingPointSet *> aps(a.size());
std::copy(a.begin(),a.end(),aps.begin());
- DataArrayDouble *pts=mergeNodesArray(aps);
+ DataArrayDouble *pts=MergeNodesArray(aps);
MEDCouplingAutoRefCountObjectPtr<MEDCouplingUMesh> ret=MEDCouplingUMesh::New("merge",meshDim);
ret->setCoords(pts);
pts->decrRef();
*cPtr=-1;
}
}
- offset=curCI[curNbOfCell];
+ offset=*(cIPtr-1);
offset2+=(*it)->getNumberOfNodes();
}
//
}
/*!
- * Idem mergeUMeshes except that 'meshes' are expected to lyie on the same coords and 'meshes' have the same meshdim.
+ * Idem MergeUMeshes except that 'meshes' are expected to lyie on the same coords and 'meshes' have the same meshdim.
* 'meshes' must be a non empty vector.
*/
-MEDCouplingUMesh *MEDCouplingUMesh::mergeUMeshesOnSameCoords(const MEDCouplingUMesh *mesh1, const MEDCouplingUMesh *mesh2) throw(INTERP_KERNEL::Exception)
+MEDCouplingUMesh *MEDCouplingUMesh::MergeUMeshesOnSameCoords(const MEDCouplingUMesh *mesh1, const MEDCouplingUMesh *mesh2) throw(INTERP_KERNEL::Exception)
{
- std::vector<MEDCouplingUMesh *> tmp(2);
- tmp[0]=const_cast<MEDCouplingUMesh *>(mesh1); tmp[1]=const_cast<MEDCouplingUMesh *>(mesh2);
- return mergeUMeshesOnSameCoords(tmp);
+ std::vector<const MEDCouplingUMesh *> tmp(2);
+ tmp[0]=mesh1; tmp[1]=mesh2;
+ return MergeUMeshesOnSameCoords(tmp);
}
/*!
- * Idem mergeUMeshes except that 'meshes' are expected to lyie on the same coords and 'meshes' have the same meshdim.
+ * Idem MergeUMeshes except that 'meshes' are expected to lyie on the same coords and 'meshes' have the same meshdim.
* 'meshes' must be a non empty vector.
*/
-MEDCouplingUMesh *MEDCouplingUMesh::mergeUMeshesOnSameCoords(const std::vector<MEDCouplingUMesh *>& meshes)
+MEDCouplingUMesh *MEDCouplingUMesh::MergeUMeshesOnSameCoords(const std::vector<const MEDCouplingUMesh *>& meshes)
{
if(meshes.empty())
throw INTERP_KERNEL::Exception("meshes input parameter is expected to be non empty.");
DataArrayDouble *coords=meshes.front()->getCoords();
int meshDim=meshes.front()->getMeshDimension();
- std::vector<MEDCouplingUMesh *>::const_iterator iter=meshes.begin();
+ std::vector<const MEDCouplingUMesh *>::const_iterator iter=meshes.begin();
int meshLgth=0;
int meshIndexLgth=0;
for(;iter!=meshes.end();iter++)
if(coords!=(*iter)->getCoords())
throw INTERP_KERNEL::Exception("meshes does not share the same coords ! Try using tryToShareSameCoords method !");
if(meshDim!=(*iter)->getMeshDimension())
- throw INTERP_KERNEL::Exception("Mesh dimensions mismatches, fuseUMeshesOnSameCoords impossible !");
+ throw INTERP_KERNEL::Exception("Mesh dimensions mismatches, FuseUMeshesOnSameCoords impossible !");
meshLgth+=(*iter)->getMeshLength();
meshIndexLgth+=(*iter)->getNumberOfCells();
}
* @return The mesh lying on the same coordinates than those in meshes. All cells in 'meshes' are in returned mesh with
* @exception if meshes is a empty vector or meshes are not lying on same coordinates or meshes not have the same dimension.
*/
-MEDCouplingUMesh *MEDCouplingUMesh::fuseUMeshesOnSameCoords(const std::vector<MEDCouplingUMesh *>& meshes, int compType, std::vector<DataArrayInt *>& corr)
+MEDCouplingUMesh *MEDCouplingUMesh::FuseUMeshesOnSameCoords(const std::vector<const MEDCouplingUMesh *>& meshes, int compType, std::vector<DataArrayInt *>& corr)
{
- //All checks are delegated to mergeUMeshesOnSameCoords
- MEDCouplingUMesh *ret=mergeUMeshesOnSameCoords(meshes);
+ //All checks are delegated to MergeUMeshesOnSameCoords
+ MEDCouplingUMesh *ret=MergeUMeshesOnSameCoords(meshes);
DataArrayInt *o2n=ret->zipConnectivityTraducer(compType);
corr.resize(meshes.size());
int nbOfMeshes=meshes.size();
tmp->alloc(curNbOfCells,1);
std::copy(o2nPtr+offset,o2nPtr+offset+curNbOfCells,tmp->getPointer());
offset+=curNbOfCells;
+ tmp->setName(meshes[i]->getName());
corr[i]=tmp;
}
o2n->decrRef();
int deltaz=isQuad?2*nbOfNodesPerLev:nbOfNodesPerLev;
switch(flatType)
{
- case INTERP_KERNEL::NORM_POINT0:
+ case INTERP_KERNEL::NORM_POINT1:
{
ret.push_back(connBg[1]);
ret.push_back(connBg[1]+nbOfNodesPerLev);
/*!
* This static operates only for coords in 3D. The polygon is specfied by its connectivity nodes in [begin,end).
*/
-bool MEDCouplingUMesh::isPolygonWellOriented(const double *vec, const int *begin, const int *end, const double *coords)
+bool MEDCouplingUMesh::IsPolygonWellOriented(const double *vec, const int *begin, const int *end, const double *coords)
{
double v[3]={0.,0.,0.};
int sz=std::distance(begin,end);
/*!
* The polyhedron is specfied by its connectivity nodes in [begin,end).
*/
-bool MEDCouplingUMesh::isPolyhedronWellOriented(const int *begin, const int *end, const double *coords)
+bool MEDCouplingUMesh::IsPolyhedronWellOriented(const int *begin, const int *end, const double *coords)
{
std::vector<std::pair<int,int> > edges;
int nbOfFaces=std::count(begin,end,-1)+1;
* This method tries to obtain a well oriented polyhedron.
* If the algorithm fails, an exception will be thrown.
*/
-void MEDCouplingUMesh::tryToCorrectPolyhedronOrientation(int *begin, int *end, const double *coords) throw(INTERP_KERNEL::Exception)
+void MEDCouplingUMesh::TryToCorrectPolyhedronOrientation(int *begin, int *end, const double *coords) throw(INTERP_KERNEL::Exception)
{
std::vector<std::pair<int,int> > edges;
int nbOfFaces=std::count(begin,end,-1)+1;
MEDCOUPLING_EXPORT void insertNextCell(INTERP_KERNEL::NormalizedCellType type, int size, const int *nodalConnOfCell) throw(INTERP_KERNEL::Exception);
MEDCOUPLING_EXPORT void finishInsertingCells();
MEDCOUPLING_EXPORT const std::set<INTERP_KERNEL::NormalizedCellType>& getAllTypes() const { return _types; }
+ MEDCOUPLING_EXPORT std::set<INTERP_KERNEL::NormalizedCellType> getTypesOfPart(const int *begin, const int *end) const throw(INTERP_KERNEL::Exception);
MEDCOUPLING_EXPORT void setConnectivity(DataArrayInt *conn, DataArrayInt *connIndex, bool isComputingTypes=true);
MEDCOUPLING_EXPORT DataArrayInt *getNodalConnectivity() const { return _nodal_connec; }
MEDCOUPLING_EXPORT DataArrayInt *getNodalConnectivityIndex() const { return _nodal_connec_index; }
MEDCOUPLING_EXPORT void giveElemsInBoundingBox(const double *bbox, double eps, std::vector<int>& elems);
MEDCOUPLING_EXPORT void giveElemsInBoundingBox(const INTERP_KERNEL::DirectedBoundingBox& bbox, double eps, std::vector<int>& elems);
MEDCOUPLING_EXPORT MEDCouplingFieldDouble *getMeasureField(bool isAbs) const;
+ MEDCOUPLING_EXPORT MEDCouplingFieldDouble *getPartMeasureField(bool isAbs, const int *begin, const int *end) const;
MEDCOUPLING_EXPORT MEDCouplingFieldDouble *getMeasureFieldOnNode(bool isAbs) const;
MEDCOUPLING_EXPORT MEDCouplingFieldDouble *buildOrthogonalField() const;
+ MEDCOUPLING_EXPORT MEDCouplingFieldDouble *buildPartOrthogonalField(const int *begin, const int *end) const;
MEDCOUPLING_EXPORT MEDCouplingFieldDouble *buildDirectionVectorField() const;
MEDCOUPLING_EXPORT bool isContiguous1D() const throw(INTERP_KERNEL::Exception);
MEDCOUPLING_EXPORT void project1D(const double *pt, const double *v, double eps, double *res) const;
MEDCOUPLING_EXPORT void getCellsContainingPoints(const double *pos, int nbOfPoints, double eps, std::vector<int>& elts, std::vector<int>& eltsIndex) const;
MEDCOUPLING_EXPORT void checkButterflyCells(std::vector<int>& cells) const;
MEDCOUPLING_EXPORT void getBoundingBoxForBBTree(std::vector<double>& bbox) const;
- MEDCOUPLING_EXPORT MEDCouplingUMesh *buildExtrudedMeshFromThis(const MEDCouplingUMesh *mesh1D, int policy);
+ MEDCOUPLING_EXPORT MEDCouplingUMesh *buildExtrudedMesh(const MEDCouplingUMesh *mesh1D, int policy);
MEDCOUPLING_EXPORT bool isFullyQuadratic() const;
MEDCOUPLING_EXPORT bool isPresenceOfQuadratic() const;
MEDCOUPLING_EXPORT void convertQuadraticCellsToLinear() throw(INTERP_KERNEL::Exception);
MEDCOUPLING_EXPORT DataArrayInt *getRenumArrForConsecutiveCellTypesSpec(const INTERP_KERNEL::NormalizedCellType *orderBg, const INTERP_KERNEL::NormalizedCellType *orderEnd) const;
MEDCOUPLING_EXPORT DataArrayInt *rearrange2ConsecutiveCellTypes();
MEDCOUPLING_EXPORT std::vector<MEDCouplingUMesh *> splitByType() const;
+ MEDCOUPLING_EXPORT DataArrayInt *keepCellIdsByType(INTERP_KERNEL::NormalizedCellType type, const int *begin, const int *end) const throw(INTERP_KERNEL::Exception);
MEDCOUPLING_EXPORT DataArrayInt *convertCellArrayPerGeoType(const DataArrayInt *da) const throw(INTERP_KERNEL::Exception);
MEDCOUPLING_EXPORT MEDCouplingUMesh *keepSpecifiedCells(INTERP_KERNEL::NormalizedCellType type, const std::vector<int>& idsPerGeoType) const;
//
MEDCOUPLING_EXPORT MEDCouplingMesh *mergeMyselfWith(const MEDCouplingMesh *other) const;
MEDCOUPLING_EXPORT DataArrayDouble *getBarycenterAndOwner() const;
- MEDCOUPLING_EXPORT static MEDCouplingUMesh *mergeUMeshes(const MEDCouplingUMesh *mesh1, const MEDCouplingUMesh *mesh2) throw(INTERP_KERNEL::Exception);
- MEDCOUPLING_EXPORT static MEDCouplingUMesh *mergeUMeshes(std::vector<const MEDCouplingUMesh *>& a) throw(INTERP_KERNEL::Exception);
- MEDCOUPLING_EXPORT static MEDCouplingUMesh *mergeUMeshesOnSameCoords(const MEDCouplingUMesh *mesh1, const MEDCouplingUMesh *mesh2) throw(INTERP_KERNEL::Exception);
- MEDCOUPLING_EXPORT static MEDCouplingUMesh *mergeUMeshesOnSameCoords(const std::vector<MEDCouplingUMesh *>& meshes);
- MEDCOUPLING_EXPORT static MEDCouplingUMesh *fuseUMeshesOnSameCoords(const std::vector<MEDCouplingUMesh *>& meshes, int compType, std::vector<DataArrayInt *>& corr);
- MEDCOUPLING_EXPORT static bool isPolygonWellOriented(const double *vec, const int *begin, const int *end, const double *coords);
- MEDCOUPLING_EXPORT static bool isPolyhedronWellOriented(const int *begin, const int *end, const double *coords);
- MEDCOUPLING_EXPORT static void tryToCorrectPolyhedronOrientation(int *begin, int *end, const double *coords) throw(INTERP_KERNEL::Exception);
+ MEDCOUPLING_EXPORT DataArrayDouble *getPartBarycenterAndOwner(const int *begin, const int *end) const;
+ MEDCOUPLING_EXPORT static MEDCouplingUMesh *MergeUMeshes(const MEDCouplingUMesh *mesh1, const MEDCouplingUMesh *mesh2) throw(INTERP_KERNEL::Exception);
+ MEDCOUPLING_EXPORT static MEDCouplingUMesh *MergeUMeshes(std::vector<const MEDCouplingUMesh *>& a) throw(INTERP_KERNEL::Exception);
+ MEDCOUPLING_EXPORT static MEDCouplingUMesh *MergeUMeshesOnSameCoords(const MEDCouplingUMesh *mesh1, const MEDCouplingUMesh *mesh2) throw(INTERP_KERNEL::Exception);
+ MEDCOUPLING_EXPORT static MEDCouplingUMesh *MergeUMeshesOnSameCoords(const std::vector<const MEDCouplingUMesh *>& meshes);
+ MEDCOUPLING_EXPORT static MEDCouplingUMesh *FuseUMeshesOnSameCoords(const std::vector<const MEDCouplingUMesh *>& meshes, int compType, std::vector<DataArrayInt *>& corr);
+ MEDCOUPLING_EXPORT static bool IsPolygonWellOriented(const double *vec, const int *begin, const int *end, const double *coords);
+ MEDCOUPLING_EXPORT static bool IsPolyhedronWellOriented(const int *begin, const int *end, const double *coords);
+ MEDCOUPLING_EXPORT static void TryToCorrectPolyhedronOrientation(int *begin, int *end, const double *coords) throw(INTERP_KERNEL::Exception);
private:
MEDCouplingUMesh();
MEDCouplingUMesh(const MEDCouplingUMesh& other, bool deepCpy);
void MEDCouplingUMeshDesc::setConnectivity(DataArrayInt *descConn, DataArrayInt *descConnIndex, DataArrayInt *nodalFaceConn, DataArrayInt *nodalFaceConnIndx)
{
- DataArrayInt::setArrayIn(descConn,_desc_connec);
- DataArrayInt::setArrayIn(descConnIndex,_desc_connec_index);
- DataArrayInt::setArrayIn(nodalFaceConn,_nodal_connec_face);
- DataArrayInt::setArrayIn(nodalFaceConnIndx,_nodal_connec_face_index);
+ DataArrayInt::SetArrayIn(descConn,_desc_connec);
+ DataArrayInt::SetArrayIn(descConnIndex,_desc_connec_index);
+ DataArrayInt::SetArrayIn(nodalFaceConn,_nodal_connec_face);
+ DataArrayInt::SetArrayIn(nodalFaceConnIndx,_nodal_connec_face_index);
computeTypes();
}
CPPUNIT_TEST( testBuildOrthogonalField2 );
CPPUNIT_TEST( testUMInsertNextCell1 );
CPPUNIT_TEST( testFieldOperatorDivDiffComp1 );
+ CPPUNIT_TEST( testDARearrange1 );
+ CPPUNIT_TEST( testGetDifferentValues1 );
+ CPPUNIT_TEST( testDAIBuildPermutationArr1 );
+ CPPUNIT_TEST( testAreCellsIncludedIn2 );
+ CPPUNIT_TEST( testUMeshGetPartBarycenterAndOwner1 );
+ CPPUNIT_TEST( testUMeshGetPartMeasureField1 );
+ CPPUNIT_TEST( testUMeshBuildPartOrthogonalField1 );
+ CPPUNIT_TEST( testUMeshGetTypesOfPart1 );
+ CPPUNIT_TEST( testUMeshKeepCellIdsByType1 );
+ CPPUNIT_TEST( testDAIAggregateMulti1 );
//MEDCouplingBasicsTestInterp.cxx
CPPUNIT_TEST( test2DInterpP0P0_1 );
CPPUNIT_TEST( test2DInterpP0P0PL_1 );
void testBuildOrthogonalField2();
void testUMInsertNextCell1();
void testFieldOperatorDivDiffComp1();
+ void testDARearrange1();
+ void testGetDifferentValues1();
+ void testDAIBuildPermutationArr1();
+ void testAreCellsIncludedIn2();
+ void testUMeshGetPartBarycenterAndOwner1();
+ void testUMeshGetPartMeasureField1();
+ void testUMeshBuildPartOrthogonalField1();
+ void testUMeshGetTypesOfPart1();
+ void testUMeshKeepCellIdsByType1();
+ void testDAIAggregateMulti1();
//MEDCouplingBasicsTestInterp.cxx
void test2DInterpP0P0_1();
void test2DInterpP0P0PL_1();
void MEDCouplingBasicsTest::testMeshPointsCloud()
{
double targetCoords[27]={-0.3,-0.3,0.5, 0.2,-0.3,1., 0.7,-0.3,1.5, -0.3,0.2,0.5, 0.2,0.2,1., 0.7,0.2,1.5, -0.3,0.7,0.5, 0.2,0.7,1., 0.7,0.7,1.5};
- int *targetConn=0;
+ const int targetConn[]={0,1,2,3,4,5,7,6};
MEDCouplingUMesh *targetMesh=MEDCouplingUMesh::New();
targetMesh->setMeshDimension(0);
targetMesh->allocateCells(8);
- targetMesh->insertNextCell(INTERP_KERNEL::NORM_POINT0,0,targetConn);
- targetMesh->insertNextCell(INTERP_KERNEL::NORM_POINT0,0,targetConn);
- targetMesh->insertNextCell(INTERP_KERNEL::NORM_POINT0,0,targetConn);
- targetMesh->insertNextCell(INTERP_KERNEL::NORM_POINT0,0,targetConn);
- targetMesh->insertNextCell(INTERP_KERNEL::NORM_POINT0,0,targetConn);
- targetMesh->insertNextCell(INTERP_KERNEL::NORM_POINT0,0,targetConn);
- targetMesh->insertNextCell(INTERP_KERNEL::NORM_POINT0,0,targetConn);
- targetMesh->insertNextCell(INTERP_KERNEL::NORM_POINT0,0,targetConn);
+ targetMesh->insertNextCell(INTERP_KERNEL::NORM_POINT1,1,targetConn);
+ targetMesh->insertNextCell(INTERP_KERNEL::NORM_POINT1,1,targetConn+1);
+ targetMesh->insertNextCell(INTERP_KERNEL::NORM_POINT1,1,targetConn+2);
+ targetMesh->insertNextCell(INTERP_KERNEL::NORM_POINT1,1,targetConn+3);
+ targetMesh->insertNextCell(INTERP_KERNEL::NORM_POINT1,1,targetConn+4);
+ targetMesh->insertNextCell(INTERP_KERNEL::NORM_POINT1,1,targetConn+5);
+ targetMesh->insertNextCell(INTERP_KERNEL::NORM_POINT1,1,targetConn+6);
+ targetMesh->insertNextCell(INTERP_KERNEL::NORM_POINT1,1,targetConn+7);
targetMesh->finishInsertingCells();
DataArrayDouble *myCoords=DataArrayDouble::New();
myCoords->alloc(9,3);
CPPUNIT_ASSERT(m3);
m2->decrRef();
MEDCouplingUMesh *m4=build2DSourceMesh_1();
- MEDCouplingUMesh *m5=MEDCouplingUMesh::mergeUMeshes(m1,m3);
+ MEDCouplingUMesh *m5=MEDCouplingUMesh::MergeUMeshes(m1,m3);
m1->decrRef();
m3->decrRef();
- MEDCouplingUMesh *m6=MEDCouplingUMesh::mergeUMeshes(m5,m4);
+ MEDCouplingUMesh *m6=MEDCouplingUMesh::MergeUMeshes(m5,m4);
m4->decrRef();
m5->decrRef();
//
}
/*!
- * This test check MEDCouplingUMesh::buildExtrudedMeshFromThis method.
+ * This test check MEDCouplingUMesh::buildExtrudedMesh method.
*/
void MEDCouplingBasicsTest::testExtrudedMesh3()
{
double center[3]={0.,0.,0.};
double vector[3]={0,1,0};
m2->rotate(center,vector,-M_PI/2.);
- MEDCouplingUMesh *m3=m1->buildExtrudedMeshFromThis(m2,0);
+ MEDCouplingUMesh *m3=m1->buildExtrudedMesh(m2,0);
//
MEDCouplingExtrudedMesh *m4=MEDCouplingExtrudedMesh::New(m3,m1,0);
CPPUNIT_ASSERT_EQUAL(15,m4->getNumberOfCells());
//play with polygons and polyedrons
std::vector<int> cells(2); cells[0]=2; cells[1]=3;
m1->convertToPolyTypes(cells);
- m3=m1->buildExtrudedMeshFromThis(m2,0);
+ m3=m1->buildExtrudedMesh(m2,0);
CPPUNIT_ASSERT_EQUAL((int)INTERP_KERNEL::NORM_HEXA8,(int)m3->getTypeOfCell(0));
CPPUNIT_ASSERT_EQUAL((int)INTERP_KERNEL::NORM_PENTA6,(int)m3->getTypeOfCell(1));
CPPUNIT_ASSERT_EQUAL((int)INTERP_KERNEL::NORM_POLYHED,(int)m3->getTypeOfCell(2));
}
/*!
- * This test check MEDCouplingUMesh::buildExtrudedMeshFromThis method, but also, MEDCouplingExtrudedMesh following methods :
+ * This test check MEDCouplingUMesh::buildExtrudedMesh method, but also, MEDCouplingExtrudedMesh following methods :
* getCellContainingPoint getMeasureField getNodeIdsOfCell getCoordinateOfNode getTypeOfCell build3DUnstructuredMesh.
*/
void MEDCouplingBasicsTest::testExtrudedMesh4()
double center[3]={0.,0.,0.};
double vector[3]={0.,1.,0.};
m2->rotate(center,vector,-M_PI/2.);
- MEDCouplingUMesh *m3=m1->buildExtrudedMeshFromThis(m2,0);
+ MEDCouplingUMesh *m3=m1->buildExtrudedMesh(m2,0);
const int expected1[15]= {1,3,2,0,6,5,7,10,11,8,12,9,14,13,4};
const int rexpected1[15]={3, 0, 2, 1, 14, 5, 4, 6, 9, 11, 7, 8, 10, 13, 12};
m3->renumberCells(expected1,false);
m1->tryToShareSameCoords(*m2,1e-12);
MEDCouplingUMesh *m3=build2DTargetMesh_1();
m3->tryToShareSameCoords(*m2,1e-12);
- std::vector<MEDCouplingUMesh *> meshes;
+ std::vector<const MEDCouplingUMesh *> meshes;
meshes.push_back(m1); meshes.push_back(m2); meshes.push_back(m3);
- MEDCouplingUMesh *m4=MEDCouplingUMesh::mergeUMeshesOnSameCoords(meshes);
+ MEDCouplingUMesh *m4=MEDCouplingUMesh::MergeUMeshesOnSameCoords(meshes);
m4->checkCoherency();
CPPUNIT_ASSERT(m4->getCoords()==m1->getCoords());
CPPUNIT_ASSERT_EQUAL(15,m4->getNumberOfCells());
m2->translate(vec);
MEDCouplingFieldDouble *f1=m1->getMeasureField(true);
MEDCouplingFieldDouble *f2=m2->getMeasureField(true);
- MEDCouplingFieldDouble *f3=MEDCouplingFieldDouble::mergeFields(f1,f2);
+ MEDCouplingFieldDouble *f3=MEDCouplingFieldDouble::MergeFields(f1,f2);
f3->checkCoherency();
MEDCouplingUMesh *m4=build2DTargetMeshMerged_1();
CPPUNIT_ASSERT(f3->getMesh()->isEqual(m4,1.e-12));
MEDCouplingUMesh *m1=build3DSurfTargetMesh_1();
std::vector<MEDCouplingUMesh *> v=m1->splitByType();
CPPUNIT_ASSERT_EQUAL(3,(int)v.size());
- MEDCouplingUMesh *m2=MEDCouplingUMesh::mergeUMeshesOnSameCoords(v);
+ std::vector<const MEDCouplingUMesh *> v2(v.begin(),v.end());
+ MEDCouplingUMesh *m2=MEDCouplingUMesh::MergeUMeshesOnSameCoords(v2);
m2->setName(m1->getName());
CPPUNIT_ASSERT(m1->isEqual(m2,1.e-12));
for(std::vector<MEDCouplingUMesh *>::const_iterator iter=v.begin();iter!=v.end();iter++)
void MEDCouplingBasicsTest::testFuseUMeshesOnSameCoords()
{
- std::vector<MEDCouplingUMesh *> meshes;
+ std::vector<const MEDCouplingUMesh *> meshes;
MEDCouplingUMesh *m2=build2DTargetMesh_1();
int cells1[3]={2,3,4};
MEDCouplingPointSet *m3_1=m2->buildPartOfMySelf(cells1,cells1+3,true);
m2->decrRef();
//
std::vector<DataArrayInt *> corr;
- MEDCouplingUMesh *m7=MEDCouplingUMesh::fuseUMeshesOnSameCoords(meshes,0,corr);
+ MEDCouplingUMesh *m7=MEDCouplingUMesh::FuseUMeshesOnSameCoords(meshes,0,corr);
CPPUNIT_ASSERT_EQUAL(4,m7->getNumberOfCells());
CPPUNIT_ASSERT_EQUAL(3,(int)corr.size());
const int expectedVals1[3]={3,3,2};
CPPUNIT_ASSERT_EQUAL(expectedVals2[i][j],vals[j]);
}
std::vector< std::vector<int> > fidsOfGroups;
- DataArrayInt *arr2=DataArrayInt::makePartition(corr,m7->getNumberOfCells(),fidsOfGroups);
+ std::vector<const DataArrayInt *> corr2(corr.begin(),corr.end());
+ DataArrayInt *arr2=DataArrayInt::MakePartition(corr2,m7->getNumberOfCells(),fidsOfGroups);
const int fidExp[4]={5,1,3,4};
const int fidsGrp[3][3]={{1,3,5},{3,4,5},{4,5,23344}};
CPPUNIT_ASSERT_EQUAL(3,(int)fidsOfGroups.size());
MEDCouplingUMesh *m3=(MEDCouplingUMesh *)m1->buildPartOfMySelf(part1,part1+5,true);
const int part2[4]={5,6,4,7};
MEDCouplingUMesh *m4=(MEDCouplingUMesh *)m1->buildPartOfMySelf(part2,part2+4,true);
- std::vector<MEDCouplingUMesh *> meshes;
+ std::vector<const MEDCouplingUMesh *> meshes;
meshes.push_back(m1);
meshes.push_back(m3);
meshes.push_back(m3);
meshes.push_back(m4);
std::vector<DataArrayInt *> corr;
- MEDCouplingUMesh *m5=MEDCouplingUMesh::fuseUMeshesOnSameCoords(meshes,0,corr);
+ MEDCouplingUMesh *m5=MEDCouplingUMesh::FuseUMeshesOnSameCoords(meshes,0,corr);
CPPUNIT_ASSERT_EQUAL(18,m5->getNumberOfCells());
std::vector<DataArrayInt *>::iterator it=corr.begin();
const int exp1[4]={18,5,5,4};
CPPUNIT_ASSERT(std::equal(t2.begin(),t2.end(),expectedValues2));
//2D with no help of bounding box.
double center[2]={0.2,0.2};
- MEDCouplingPointSet::rotate2DAlg(center,0.78539816339744830962,6,pos);
+ MEDCouplingPointSet::Rotate2DAlg(center,0.78539816339744830962,6,pos);
targetMesh->rotate(center,0,0.78539816339744830962);
t1.clear(); t2.clear();
targetMesh->getCellsContainingPoints(pos,6,1e-12,t1,t2);
double center[3]={0.,0.,0.};
double vector[3]={0.,1.,0.};
m4->rotate(center,vector,-M_PI/2.);
- MEDCouplingUMesh *m5=m3->buildExtrudedMeshFromThis(m4,0);
+ MEDCouplingUMesh *m5=m3->buildExtrudedMesh(m4,0);
res1.clear();
m5->arePolyhedronsNotCorrectlyOriented(res1);
CPPUNIT_ASSERT_EQUAL(15,(int)res1.size());
CPPUNIT_ASSERT(m3);
m2->decrRef();
MEDCouplingUMesh *m4=build2DSourceMesh_1();
- MEDCouplingUMesh *m5=MEDCouplingUMesh::mergeUMeshes(m1,m3);
+ MEDCouplingUMesh *m5=MEDCouplingUMesh::MergeUMeshes(m1,m3);
m1->decrRef();
m3->decrRef();
- MEDCouplingUMesh *m6=MEDCouplingUMesh::mergeUMeshes(m5,m4);
+ MEDCouplingUMesh *m6=MEDCouplingUMesh::MergeUMeshes(m5,m4);
m4->decrRef();
m5->decrRef();
//
tmp->alloc(3,2);
const double vals[6]={0.2,0.2,0.1,0.2,0.2,0.2};
std::copy(vals,vals+6,tmp->getPointer());
- DataArrayDouble *tmp2=DataArrayDouble::aggregate(coords,tmp);
+ DataArrayDouble *tmp2=DataArrayDouble::Aggregate(coords,tmp);
tmp->decrRef();
mesh->setCoords(tmp2);
tmp2->decrRef();
DataArrayDouble *g=f->getCoords()->applyFunc(2,"3.5*IVec+x/6*3.14159265359*JVec");
DataArrayDouble *h=g->fromPolarToCart();
f->setCoords(h);
- MEDCouplingUMesh *i=c->buildExtrudedMeshFromThis(f,1);
+ MEDCouplingUMesh *i=c->buildExtrudedMesh(f,1);
CPPUNIT_ASSERT_EQUAL(52,i->getNumberOfNodes());
bool tmp2;
int tmp3;
//
const double center[2]={0.,0.};
f->rotate(center,0,M_PI/3);
- MEDCouplingUMesh *g=c->buildExtrudedMeshFromThis(f,0);
+ MEDCouplingUMesh *g=c->buildExtrudedMesh(f,0);
g->checkCoherency();
const double expected1[]={ 0.4330127018922193, 0.4330127018922193, 0.649519052838329, 1.2990381056766578, 1.299038105676658, 1.948557158514987, 2.1650635094610955, 2.1650635094610964, 3.2475952641916446, 3.031088913245533, 3.0310889132455352, 4.546633369868303 };
MEDCouplingFieldDouble *f1=g->getMeasureField(true);
DataArrayDouble *g=f->getCoords()->applyFunc(2,"3.5*IVec+x/6*3.14159265359*JVec");
DataArrayDouble *h=g->fromPolarToCart();
f->setCoords(h);
- MEDCouplingUMesh *i=c->buildExtrudedMeshFromThis(f,1);
+ MEDCouplingUMesh *i=c->buildExtrudedMesh(f,1);
CPPUNIT_ASSERT_EQUAL(52,i->getNumberOfNodes());
bool tmp2;
int tmp3;
DataArrayDouble *g2=h->applyFunc(3,"13.5/3.5*x*IVec+0*JVec+13.5/3.5*y*KVec");
f->setCoords(g2);
i->changeSpaceDimension(3);
- MEDCouplingUMesh *i3=i->buildExtrudedMeshFromThis(f,1);
+ MEDCouplingUMesh *i3=i->buildExtrudedMesh(f,1);
MEDCouplingFieldDouble *f2=i3->getMeasureField(true);
tmp=i->mergeNodes(1e-9,tmp2,tmp3);
CPPUNIT_ASSERT(tmp2);
for(int i=0;i<35;i++)
CPPUNIT_ASSERT_EQUAL((int)expected1[i],dai1->getIJ(0,i));
// test of static method DataArrayDouble::meld
- DataArrayDouble *da4=DataArrayDouble::meld(da1C,da3);
+ DataArrayDouble *da4=DataArrayDouble::Meld(da1C,da3);
CPPUNIT_ASSERT_EQUAL(5,da4->getNumberOfComponents());
CPPUNIT_ASSERT_EQUAL(7,da4->getNumberOfTuples());
CPPUNIT_ASSERT(da4->getInfoOnComponent(0)=="c0da1");
// test of static method DataArrayInt::meld
dai1->decrRef();
dai1=da1C->convertToIntArr();
- DataArrayInt *dai4=DataArrayInt::meld(dai1,dai3);
+ DataArrayInt *dai4=DataArrayInt::Meld(dai1,dai3);
CPPUNIT_ASSERT_EQUAL(5,dai4->getNumberOfComponents());
CPPUNIT_ASSERT_EQUAL(7,dai4->getNumberOfTuples());
CPPUNIT_ASSERT(dai4->getInfoOnComponent(0)=="c0da1");
f2->getArray()->setInfoOnComponent(1,"ccc");
f2->checkCoherency();
//
- MEDCouplingFieldDouble *f3=MEDCouplingFieldDouble::meldFields(f2,f1);
+ MEDCouplingFieldDouble *f3=MEDCouplingFieldDouble::MeldFields(f2,f1);
f3->checkCoherency();
CPPUNIT_ASSERT_EQUAL(5,f3->getNumberOfTuples());
CPPUNIT_ASSERT_EQUAL(3,f3->getNumberOfComponents());
//
MEDCouplingFieldDouble *f4=f2->buildNewTimeReprFromThis(NO_TIME,false);
MEDCouplingFieldDouble *f5=f1->buildNewTimeReprFromThis(NO_TIME,false);
- MEDCouplingFieldDouble *f6=MEDCouplingFieldDouble::meldFields(f4,f5);
+ MEDCouplingFieldDouble *f6=MEDCouplingFieldDouble::MeldFields(f4,f5);
f6->checkCoherency();
CPPUNIT_ASSERT_EQUAL(5,f6->getNumberOfTuples());
CPPUNIT_ASSERT_EQUAL(3,f6->getNumberOfComponents());
std::vector<const MEDCouplingUMesh *> tmp(2);
tmp[0]=m1;
tmp[1]=m2;
- MEDCouplingUMesh *m3=MEDCouplingUMesh::mergeUMeshes(tmp);
+ MEDCouplingUMesh *m3=MEDCouplingUMesh::MergeUMeshes(tmp);
bool b;
int newNbOfNodes;
DataArrayInt *da=m3->mergeNodes2(0.01,b,newNbOfNodes);
//
std::vector<const MEDCouplingFieldDouble *> tmp(3);
tmp[0]=f1; tmp[1]=f2; tmp[2]=f3;
- MEDCouplingFieldDouble *f4=MEDCouplingFieldDouble::mergeFields(tmp);
+ MEDCouplingFieldDouble *f4=MEDCouplingFieldDouble::MergeFields(tmp);
CPPUNIT_ASSERT_EQUAL(15,f4->getMesh()->getNumberOfCells());
const double expected1[30]={2.,2.,2.,2.,2.,2.,2.,2.,2.,2., 5.,5.,5.,5.,5.,5.,5.,5.,5.,5., 7.,7.,7.,7.,7.,7.,7.,7.,7.,7.};
for(int i=0;i<30;i++)
targetMesh->insertNextCell(INTERP_KERNEL::NORM_QUAD4,4,targetConn);
CPPUNIT_ASSERT_THROW(targetMesh->insertNextCell(INTERP_KERNEL::NORM_TETRA4,4,targetConn),INTERP_KERNEL::Exception);
CPPUNIT_ASSERT_THROW(targetMesh->insertNextCell(INTERP_KERNEL::NORM_SEG2,2,targetConn),INTERP_KERNEL::Exception);
- CPPUNIT_ASSERT_THROW(targetMesh->insertNextCell(INTERP_KERNEL::NORM_POINT0,1,targetConn),INTERP_KERNEL::Exception);
+ CPPUNIT_ASSERT_THROW(targetMesh->insertNextCell(INTERP_KERNEL::NORM_POINT1,1,targetConn),INTERP_KERNEL::Exception);
targetMesh->insertNextCell(INTERP_KERNEL::NORM_TRI3,3,targetConn+4);
targetMesh->insertNextCell(INTERP_KERNEL::NORM_TRI3,3,targetConn+7);
targetMesh->insertNextCell(INTERP_KERNEL::NORM_QUAD4,4,targetConn+10);
d4->decrRef();
m->decrRef();
}
+
+void MEDCouplingBasicsTest::testDARearrange1()
+{
+ DataArrayInt *da1=DataArrayInt::New();
+ da1->alloc(12,1);
+ da1->iota(0);
+ const int *ptr=da1->getConstPointer();
+ //
+ CPPUNIT_ASSERT_EQUAL(12,da1->getNbOfElems());
+ CPPUNIT_ASSERT_EQUAL(1,da1->getNumberOfComponents());
+ CPPUNIT_ASSERT_EQUAL(12,da1->getNumberOfTuples());
+ da1->rearrange(4);
+ CPPUNIT_ASSERT(ptr==da1->getConstPointer());
+ CPPUNIT_ASSERT_EQUAL(12,da1->getNbOfElems());
+ CPPUNIT_ASSERT_EQUAL(4,da1->getNumberOfComponents());
+ CPPUNIT_ASSERT_EQUAL(3,da1->getNumberOfTuples());
+ for(int i=0;i<12;i++)
+ CPPUNIT_ASSERT_EQUAL(i,da1->getIJ(0,i));
+ //
+ da1->rearrange(6);
+ CPPUNIT_ASSERT(ptr==da1->getConstPointer());
+ CPPUNIT_ASSERT_EQUAL(12,da1->getNbOfElems());
+ CPPUNIT_ASSERT_EQUAL(6,da1->getNumberOfComponents());
+ CPPUNIT_ASSERT_EQUAL(2,da1->getNumberOfTuples());
+ for(int i=0;i<12;i++)
+ CPPUNIT_ASSERT_EQUAL(i,da1->getIJ(0,i));
+ //
+ CPPUNIT_ASSERT_THROW(da1->rearrange(7),INTERP_KERNEL::Exception);
+ //
+ da1->rearrange(12);
+ CPPUNIT_ASSERT(ptr==da1->getConstPointer());
+ CPPUNIT_ASSERT_EQUAL(12,da1->getNbOfElems());
+ CPPUNIT_ASSERT_EQUAL(12,da1->getNumberOfComponents());
+ CPPUNIT_ASSERT_EQUAL(1,da1->getNumberOfTuples());
+ for(int i=0;i<12;i++)
+ CPPUNIT_ASSERT_EQUAL(i,da1->getIJ(0,i));
+ //
+ da1->rearrange(3);
+ CPPUNIT_ASSERT(ptr==da1->getConstPointer());
+ CPPUNIT_ASSERT_EQUAL(12,da1->getNbOfElems());
+ CPPUNIT_ASSERT_EQUAL(3,da1->getNumberOfComponents());
+ CPPUNIT_ASSERT_EQUAL(4,da1->getNumberOfTuples());
+ for(int i=0;i<12;i++)
+ CPPUNIT_ASSERT_EQUAL(i,da1->getIJ(0,i));
+ //double
+ DataArrayDouble *da2=da1->convertToDblArr();
+ da1->decrRef();
+ const double *ptr2=da2->getConstPointer();
+ //
+ CPPUNIT_ASSERT_EQUAL(12,da2->getNbOfElems());
+ CPPUNIT_ASSERT_EQUAL(3,da2->getNumberOfComponents());
+ CPPUNIT_ASSERT_EQUAL(4,da2->getNumberOfTuples());
+ da2->rearrange(4);
+ CPPUNIT_ASSERT(ptr2==da2->getConstPointer());
+ CPPUNIT_ASSERT_EQUAL(12,da2->getNbOfElems());
+ CPPUNIT_ASSERT_EQUAL(4,da2->getNumberOfComponents());
+ CPPUNIT_ASSERT_EQUAL(3,da2->getNumberOfTuples());
+ for(int i=0;i<12;i++)
+ CPPUNIT_ASSERT_DOUBLES_EQUAL((double)i,da2->getIJ(0,i),1e-14);
+ //
+ da2->rearrange(6);
+ CPPUNIT_ASSERT(ptr2==da2->getConstPointer());
+ CPPUNIT_ASSERT_EQUAL(12,da2->getNbOfElems());
+ CPPUNIT_ASSERT_EQUAL(6,da2->getNumberOfComponents());
+ CPPUNIT_ASSERT_EQUAL(2,da2->getNumberOfTuples());
+ for(int i=0;i<12;i++)
+ CPPUNIT_ASSERT_DOUBLES_EQUAL((double)i,da2->getIJ(0,i),1e-14);
+ //
+ CPPUNIT_ASSERT_THROW(da2->rearrange(7),INTERP_KERNEL::Exception);
+ //
+ da2->rearrange(1);
+ CPPUNIT_ASSERT(ptr2==da2->getConstPointer());
+ CPPUNIT_ASSERT_EQUAL(12,da2->getNbOfElems());
+ CPPUNIT_ASSERT_EQUAL(1,da2->getNumberOfComponents());
+ CPPUNIT_ASSERT_EQUAL(12,da2->getNumberOfTuples());
+ for(int i=0;i<12;i++)
+ CPPUNIT_ASSERT_DOUBLES_EQUAL((double)i,da2->getIJ(0,i),1e-14);
+ //
+ da2->rearrange(3);
+ CPPUNIT_ASSERT(ptr2==da2->getConstPointer());
+ CPPUNIT_ASSERT_EQUAL(12,da2->getNbOfElems());
+ CPPUNIT_ASSERT_EQUAL(3,da2->getNumberOfComponents());
+ CPPUNIT_ASSERT_EQUAL(4,da2->getNumberOfTuples());
+ for(int i=0;i<12;i++)
+ CPPUNIT_ASSERT_DOUBLES_EQUAL((double)i,da2->getIJ(0,i),1e-14);
+ da2->decrRef();
+}
+
+void MEDCouplingBasicsTest::testGetDifferentValues1()
+{
+ DataArrayInt *da1=DataArrayInt::New();
+ const int arr[12]={1,2,3,2,2,3,5,1,5,5,2,2};
+ da1->alloc(4,3);
+ std::copy(arr,arr+12,da1->getPointer());
+ std::set<int> s=da1->getDifferentValues();
+ const int expected1[4]={1,2,3,5};
+ CPPUNIT_ASSERT_EQUAL(4,(int)s.size());
+ CPPUNIT_ASSERT(std::equal(expected1,expected1+4,s.begin()));
+ da1->decrRef();
+}
+
+void MEDCouplingBasicsTest::testDAIBuildPermutationArr1()
+{
+ DataArrayInt *a=DataArrayInt::New();
+ const int vala[5]={4,5,6,7,8};
+ a->alloc(5,1);
+ std::copy(vala,vala+5,a->getPointer());
+ DataArrayInt *b=DataArrayInt::New();
+ const int valb[5]={5,4,8,6,7};
+ b->alloc(5,1);
+ std::copy(valb,valb+5,b->getPointer());
+ DataArrayInt *c=a->buildPermutationArr(*b);
+ const int expect1[5]={1,0,4,2,3};
+ CPPUNIT_ASSERT_EQUAL(5,c->getNumberOfTuples());
+ CPPUNIT_ASSERT_EQUAL(1,c->getNumberOfComponents());
+ CPPUNIT_ASSERT(std::equal(expect1,expect1+5,c->getConstPointer()));
+ CPPUNIT_ASSERT(a->isEqualWithoutConsideringStrAndOrder(*b));
+ b->setIJ(0,0,9);
+ CPPUNIT_ASSERT(!a->isEqualWithoutConsideringStrAndOrder(*b));
+ CPPUNIT_ASSERT_THROW(a->buildPermutationArr(*b),INTERP_KERNEL::Exception);
+ a->setIJ(3,0,4);
+ b->setIJ(0,0,5);
+ b->setIJ(4,0,4);//;a==[4,5,6,4,8] and b==[5,4,8,6,4]
+ CPPUNIT_ASSERT(a->isEqualWithoutConsideringStrAndOrder(*b));
+ c->decrRef();
+ c=a->buildPermutationArr(*b);
+ const int expect2[5]={1,3,4,2,3};
+ CPPUNIT_ASSERT(std::equal(expect2,expect2+5,c->getConstPointer()));
+ DataArrayDouble *d=b->convertToDblArr();
+ b->sort();
+ const int expect3[5]={4,4,5,6,8};
+ CPPUNIT_ASSERT(std::equal(expect3,expect3+5,b->getConstPointer()));
+ d->sort();
+ CPPUNIT_ASSERT_EQUAL(5,d->getNumberOfTuples());
+ CPPUNIT_ASSERT_EQUAL(1,d->getNumberOfComponents());
+ for(int i=0;i<5;i++)
+ CPPUNIT_ASSERT_DOUBLES_EQUAL(double(expect3[i]),d->getIJ(i,0),1e-14);
+ //
+ d->decrRef();
+ c->decrRef();
+ a->decrRef();
+ b->decrRef();
+}
+
+void MEDCouplingBasicsTest::testAreCellsIncludedIn2()
+{
+ const char myName[]="Vitoo";
+ MEDCouplingUMesh *m=build3DSurfTargetMesh_1();
+ MEDCouplingUMesh *m2=(MEDCouplingUMesh *)m->buildPartOfMySelf(0,0,true);
+ CPPUNIT_ASSERT_EQUAL(0,m2->getNumberOfCells());
+ CPPUNIT_ASSERT_EQUAL(3,m2->getSpaceDimension());
+ CPPUNIT_ASSERT_EQUAL(2,m2->getMeshDimension());
+ m2->setName(myName);
+ DataArrayInt *tmp;
+ CPPUNIT_ASSERT(m->areCellsIncludedIn(m2,0,tmp));
+ CPPUNIT_ASSERT(std::string(myName)==tmp->getName());
+ CPPUNIT_ASSERT_EQUAL(0,tmp->getNumberOfTuples());
+ CPPUNIT_ASSERT_EQUAL(1,tmp->getNumberOfComponents());
+ m->decrRef();
+ m2->decrRef();
+ tmp->decrRef();
+}
+
+void MEDCouplingBasicsTest::testUMeshGetPartBarycenterAndOwner1()
+{
+ MEDCouplingUMesh *m1=build2DTargetMesh_1();
+ const int part[3]={1,0,4};
+ DataArrayDouble *b=m1->getPartBarycenterAndOwner(part,part+3);
+ CPPUNIT_ASSERT_EQUAL(2,b->getNumberOfComponents());
+ CPPUNIT_ASSERT_EQUAL(3,b->getNumberOfTuples());
+ const double expected1[6]={0.36666666666666665,-0.13333333333333333,-0.05,-0.05,0.45,0.45};
+ for(int i=0;i<6;i++)
+ CPPUNIT_ASSERT_DOUBLES_EQUAL(expected1[i],b->getIJ(0,i),1e-14);
+ b->decrRef();
+ m1->decrRef();
+}
+
+void MEDCouplingBasicsTest::testUMeshGetPartMeasureField1()
+{
+ MEDCouplingUMesh *m1=build2DTargetMesh_1();
+ const int part[3]={1,0,4};
+ MEDCouplingFieldDouble *b=m1->getPartMeasureField(true,part,part+3);
+ CPPUNIT_ASSERT_EQUAL(1,b->getArray()->getNumberOfComponents());
+ CPPUNIT_ASSERT_EQUAL(3,b->getArray()->getNumberOfTuples());
+ const double expected1[3]={0.125,0.25,0.25};
+ for(int i=0;i<3;i++)
+ CPPUNIT_ASSERT_DOUBLES_EQUAL(expected1[i],b->getArray()->getIJ(0,i),1e-14);
+ b->decrRef();
+ m1->decrRef();
+}
+
+void MEDCouplingBasicsTest::testUMeshBuildPartOrthogonalField1()
+{
+ MEDCouplingUMesh *m1=build2DTargetMesh_1();
+ m1->changeSpaceDimension(3);
+ const int part[3]={1,0,4};
+ MEDCouplingFieldDouble *b=m1->buildPartOrthogonalField(part,part+3);
+ CPPUNIT_ASSERT_EQUAL(3,b->getArray()->getNumberOfComponents());
+ CPPUNIT_ASSERT_EQUAL(3,b->getArray()->getNumberOfTuples());
+ const double expected1[9]={0.,0.,-1.,0.,0.,-1.,0.,0.,-1.};
+ for(int i=0;i<9;i++)
+ CPPUNIT_ASSERT_DOUBLES_EQUAL(expected1[i],b->getArray()->getIJ(0,i),1e-14);
+ b->decrRef();
+ m1->decrRef();
+}
+
+void MEDCouplingBasicsTest::testUMeshGetTypesOfPart1()
+{
+ MEDCouplingUMesh *m1=build2DTargetMesh_1();
+ const int part1[]={0,3,4};
+ std::set<INTERP_KERNEL::NormalizedCellType> s;
+ s=m1->getTypesOfPart(part1,part1+3);
+ CPPUNIT_ASSERT(s.size()==1);
+ CPPUNIT_ASSERT(*s.begin()==INTERP_KERNEL::NORM_QUAD4);
+ const int part2[]={2,2,2,1};
+ s=m1->getTypesOfPart(part2,part2+4);
+ CPPUNIT_ASSERT(s.size()==1);
+ CPPUNIT_ASSERT(*s.begin()==INTERP_KERNEL::NORM_TRI3);
+ const int part3[]={3,2,1};
+ s=m1->getTypesOfPart(part3,part3+3);
+ CPPUNIT_ASSERT(s.size()==2);
+ CPPUNIT_ASSERT(*s.begin()==INTERP_KERNEL::NORM_TRI3);
+ CPPUNIT_ASSERT(*(++s.begin())==INTERP_KERNEL::NORM_QUAD4);
+ m1->decrRef();
+}
+
+void MEDCouplingBasicsTest::testUMeshKeepCellIdsByType1()
+{
+ MEDCouplingUMesh *m1=build2DTargetMesh_1();
+ const int part1[3]={0,3,4};
+ DataArrayInt *a=m1->keepCellIdsByType(INTERP_KERNEL::NORM_TRI3,part1,part1+3);
+ CPPUNIT_ASSERT_EQUAL(1,a->getNumberOfComponents());
+ CPPUNIT_ASSERT_EQUAL(0,a->getNumberOfTuples());
+ a->decrRef();
+ //
+ const int part2[5]={3,2,0,2,4};
+ a=m1->keepCellIdsByType(INTERP_KERNEL::NORM_TRI3,part2,part2+5);
+ CPPUNIT_ASSERT_EQUAL(1,a->getNumberOfComponents());
+ CPPUNIT_ASSERT_EQUAL(2,a->getNumberOfTuples());
+ CPPUNIT_ASSERT_EQUAL(2,a->getIJ(0,0));
+ CPPUNIT_ASSERT_EQUAL(2,a->getIJ(1,0));
+ a->decrRef();
+ //
+ a=m1->keepCellIdsByType(INTERP_KERNEL::NORM_QUAD4,part2,part2+5);
+ CPPUNIT_ASSERT_EQUAL(1,a->getNumberOfComponents());
+ CPPUNIT_ASSERT_EQUAL(3,a->getNumberOfTuples());
+ CPPUNIT_ASSERT_EQUAL(3,a->getIJ(0,0));
+ CPPUNIT_ASSERT_EQUAL(0,a->getIJ(1,0));
+ CPPUNIT_ASSERT_EQUAL(4,a->getIJ(2,0));
+ //
+ a->decrRef();
+ m1->decrRef();
+}
+
+void MEDCouplingBasicsTest::testDAIAggregateMulti1()
+{
+ DataArrayInt *a=DataArrayInt::New();
+ a->setName("aa");
+ a->alloc(4,1);
+ a->iota(0);
+ a->rearrange(2);
+ DataArrayInt *b=DataArrayInt::New();
+ b->setName("bb");
+ b->alloc(6,1);
+ b->iota(0);
+ b->rearrange(2);
+ //
+ std::vector<const DataArrayInt *> v(2);
+ v[0]=a; v[1]=b;
+ DataArrayInt *c=DataArrayInt::Aggregate(v);
+ CPPUNIT_ASSERT_EQUAL(5,c->getNumberOfTuples());
+ CPPUNIT_ASSERT_EQUAL(2,c->getNumberOfComponents());
+ CPPUNIT_ASSERT(c->getName()=="aa");
+ const int expect1[10]={0,1,2,3,0,1,2,3,4,5};
+ for(int i=0;i<10;i++)
+ CPPUNIT_ASSERT_EQUAL(expect1[i],c->getIJ(0,i));
+ //
+ c->decrRef();
+ a->decrRef();
+ b->decrRef();
+}