declareAsNew();
}
+/*!
+ * This method expects that 'this' is allocated, if not an exception is thrown.
+ * This method in case of success returns a newly created array the user should deal with.
+ * In the case of having a renumber array in "old to new" format. More info on renumbering \ref MEDCouplingArrayRenumbering "here".
+ */
DataArrayInt *DataArrayInt::renumber(const int *old2New) const
{
int nbTuples=getNumberOfTuples();
return ret;
}
+/*!
+ * This method expects to be called when number of components of this is equal to one.
+ * This method returns true if it exists a tuple so that the value is contained in 'vals'.
+ * If not any tuple contains one of the values contained in 'vals' false is returned.
+ */
+bool DataArrayInt::presenceOfValue(const std::vector<int>& vals) const throw(INTERP_KERNEL::Exception)
+{
+ if(getNumberOfComponents()!=1)
+ throw INTERP_KERNEL::Exception("DataArrayInt::presenceOfValue : the array must have only one component, you can call 'rearrange' method before !");
+ std::set<int> vals2(vals.begin(),vals.end());
+ const int *cptr=getConstPointer();
+ int nbOfTuples=getNumberOfTuples();
+ bool found=false;
+ for(const int *w=cptr;w!=cptr+nbOfTuples && !found;w++)
+ found=(vals2.find(*w)!=vals2.end());
+ return found;
+}
+
DataArrayInt *DataArrayInt::Aggregate(const DataArrayInt *a1, const DataArrayInt *a2, int offsetA2)
{
int nbOfComp=a1->getNumberOfComponents();
MEDCOUPLING_EXPORT DataArrayInt *getIdsNotEqual(int val) const throw(INTERP_KERNEL::Exception);
MEDCOUPLING_EXPORT DataArrayInt *getIdsEqualList(const std::vector<int>& vals) const throw(INTERP_KERNEL::Exception);
MEDCOUPLING_EXPORT DataArrayInt *getIdsNotEqualList(const std::vector<int>& vals) const throw(INTERP_KERNEL::Exception);
+ MEDCOUPLING_EXPORT bool presenceOfValue(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 void applyLin(int a, int b, int compoId) throw(INTERP_KERNEL::Exception);
return (*it).second;
}
+std::vector<std::string> MEDFileMesh::getFamiliesOnGroups(const std::vector<std::string>& grps) const throw(INTERP_KERNEL::Exception)
+{
+ std::set<std::string> fams;
+ for(std::vector<std::string>::const_iterator it=grps.begin();it!=grps.end();it++)
+ {
+ std::map<std::string, std::vector<std::string> >::const_iterator it2=_groups.find(*it);
+ if(it2==_groups.end())
+ {
+ std::ostringstream oss; oss << "No such group in mesh \"" << _name << "\" : " << *it;
+ throw INTERP_KERNEL::Exception(oss.str().c_str());
+ }
+ fams.insert((*it2).second.begin(),(*it2).second.end());
+ }
+ std::vector<std::string> fams2(fams.begin(),fams.end());
+ return fams2;
+}
+
std::vector<int> MEDFileMesh::getFamiliesIdsOnGroup(const char *name) const throw(INTERP_KERNEL::Exception)
{
std::string oname(name);
DataArrayInt *MEDFileMesh::getGroupsArr(int meshDimRelToMaxExt, const std::vector<std::string>& grps, bool renum) const throw(INTERP_KERNEL::Exception)
{
- std::set<std::string> fams;
- for(std::vector<std::string>::const_iterator it=grps.begin();it!=grps.end();it++)
- {
- std::map<std::string, std::vector<std::string> >::const_iterator it2=_groups.find(*it);
- if(it2==_groups.end())
- {
- std::ostringstream oss; oss << "No such group in mesh \"" << _name << "\" : " << *it;
- throw INTERP_KERNEL::Exception(oss.str().c_str());
- }
- fams.insert((*it2).second.begin(),(*it2).second.end());
- }
- std::vector<std::string> fams2(fams.begin(),fams.end());
+ std::vector<std::string> fams2=getFamiliesOnGroups(grps);
return getFamiliesArr(meshDimRelToMaxExt,fams2,renum);
}
return ret0;
}
+/*!
+ * This methods returns all relative mesh levels where group 'grp' is defined \b excluded \b nodes.
+ * To include nodes call MEDFileUMesh::getGrpNonEmptyLevelsExt method.
+ */
+std::vector<int> MEDFileUMesh::getGrpNonEmptyLevels(const char *grp) const throw(INTERP_KERNEL::Exception)
+{
+ std::vector<std::string> fams=getFamiliesOnGroup(grp);
+ return getFamsNonEmptyLevels(fams);
+}
+
+/*!
+ * This method is a generalization of MEDFileUMesh::getGrpNonEmptyLevelsExt. It looks at the node level to state if the group 'grp' has a part lying on node.
+ */
+std::vector<int> MEDFileUMesh::getGrpNonEmptyLevelsExt(const char *grp) const throw(INTERP_KERNEL::Exception)
+{
+ std::vector<std::string> fams=getFamiliesOnGroup(grp);
+ return getFamsNonEmptyLevelsExt(fams);
+}
+
+/*!
+ * This methods returns all relative mesh levels where family 'fam' is defined \b excluded \b nodes.
+ * To include nodes call MEDFileUMesh::getFamNonEmptyLevelsExt method.
+ */
+std::vector<int> MEDFileUMesh::getFamNonEmptyLevels(const char *fam) const throw(INTERP_KERNEL::Exception)
+{
+ std::vector<std::string> fams(1,std::string(fam));
+ return getFamsNonEmptyLevels(fams);
+}
+
+/*!
+ * This method is a generalization of MEDFileUMesh::getFamNonEmptyLevels. It looks at the node level to state if the family 'fam' has a part lying on node.
+ */
+std::vector<int> MEDFileUMesh::getFamNonEmptyLevelsExt(const char *fam) const throw(INTERP_KERNEL::Exception)
+{
+ std::vector<std::string> fams(1,std::string(fam));
+ return getFamsNonEmptyLevelsExt(fams);
+}
+
+/*!
+ * This methods returns all relative mesh levels where groups 'grps' are defined \b excluded \b nodes.
+ * To include nodes call MEDFileUMesh::getGrpsNonEmptyLevelsExt method.
+ */
+std::vector<int> MEDFileUMesh::getGrpsNonEmptyLevels(const std::vector<std::string>& grps) const throw(INTERP_KERNEL::Exception)
+{
+ std::vector<std::string> fams=getFamiliesOnGroups(grps);
+ return getFamsNonEmptyLevels(fams);
+}
+
+/*!
+ * This method is a generalization of MEDFileUMesh::getGrpsNonEmptyLevels. It looks at the node level to state if the families 'fams' has a part lying on node.
+ */
+std::vector<int> MEDFileUMesh::getGrpsNonEmptyLevelsExt(const std::vector<std::string>& grps) const throw(INTERP_KERNEL::Exception)
+{
+ std::vector<std::string> fams=getFamiliesOnGroups(grps);
+ return getFamsNonEmptyLevelsExt(fams);
+}
+
+/*!
+ * This methods returns all relative mesh levels where families 'fams' are defined \b excluded \b nodes.
+ * To include nodes call MEDFileUMesh::getFamsNonEmptyLevelsExt method.
+ */
+std::vector<int> MEDFileUMesh::getFamsNonEmptyLevels(const std::vector<std::string>& fams) const throw(INTERP_KERNEL::Exception)
+{
+ std::vector<int> ret;
+ std::vector<int> levs=getNonEmptyLevels();
+ std::vector<int> famIds=getFamiliesIds(fams);
+ for(std::vector<int>::const_iterator it=levs.begin();it!=levs.end();it++)
+ if(_ms[-(*it)]->presenceOfOneFams(famIds))
+ ret.push_back(*it);
+ return ret;
+}
+
+/*!
+ * This method is a generalization of MEDFileUMesh::getFamsNonEmptyLevels. It looks at the node level to state if the families 'fams' has a part lying on node.
+ */
+std::vector<int> MEDFileUMesh::getFamsNonEmptyLevelsExt(const std::vector<std::string>& fams) const throw(INTERP_KERNEL::Exception)
+{
+ std::vector<int> ret0=getFamsNonEmptyLevels(fams);
+ const DataArrayInt *famCoords=_fam_coords;
+ if(!famCoords)
+ return ret0;
+ std::vector<int> famIds=getFamiliesIds(fams);
+ if(famCoords->presenceOfValue(famIds))
+ {
+ std::vector<int> ret(ret0.size()+1);
+ ret[0]=1;
+ std::copy(ret0.begin(),ret0.end(),ret.begin()+1);
+ return ret;
+ }
+ else
+ return ret0;
+}
+
int MEDFileUMesh::getMeshDimension() const throw(INTERP_KERNEL::Exception)
{
int lev=0;
MEDCouplingUMesh *MEDFileUMesh::getGroups(int meshDimRelToMaxExt, const std::vector<std::string>& grps, bool renum) const throw(INTERP_KERNEL::Exception)
{
synchronizeTinyInfoOnLeaves();
- std::set<std::string> fams;
- for(std::vector<std::string>::const_iterator it=grps.begin();it!=grps.end();it++)
- {
- std::map<std::string, std::vector<std::string> >::const_iterator it2=_groups.find(*it);
- if(it2==_groups.end())
- {
- std::ostringstream oss; oss << "No such group in mesh \"" << _name << "\" : " << *it;
- throw INTERP_KERNEL::Exception(oss.str().c_str());
- }
- fams.insert((*it2).second.begin(),(*it2).second.end());
- }
- std::vector<std::string> fams2(fams.begin(),fams.end());
+ std::vector<std::string> fams2=getFamiliesOnGroups(grps);
return getFamilies(meshDimRelToMaxExt,fams2,renum);
}
const std::map<std::string,int>& getFamilyInfo() const { return _families; }
const std::map<std::string, std::vector<std::string> >& getGroupInfo() const { return _groups; }
std::vector<std::string> getFamiliesOnGroup(const char *name) const throw(INTERP_KERNEL::Exception);
+ std::vector<std::string> getFamiliesOnGroups(const std::vector<std::string>& grps) const throw(INTERP_KERNEL::Exception);
std::vector<int> getFamiliesIdsOnGroup(const char *name) const throw(INTERP_KERNEL::Exception);
void setFamiliesOnGroup(const char *name, const std::vector<std::string>& fams) throw(INTERP_KERNEL::Exception);
void setFamiliesIdsOnGroup(const char *name, const std::vector<int>& famIds) throw(INTERP_KERNEL::Exception);
const DataArrayInt *getRevNumberFieldAtLevel(int meshDimRelToMaxExt) const throw(INTERP_KERNEL::Exception);
std::vector<int> getNonEmptyLevels() const;
std::vector<int> getNonEmptyLevelsExt() const;
+ std::vector<int> getGrpNonEmptyLevels(const char *grp) const throw(INTERP_KERNEL::Exception);
+ std::vector<int> getGrpNonEmptyLevelsExt(const char *grp) const throw(INTERP_KERNEL::Exception);
+ std::vector<int> getFamNonEmptyLevels(const char *fam) const throw(INTERP_KERNEL::Exception);
+ std::vector<int> getFamNonEmptyLevelsExt(const char *fam) const throw(INTERP_KERNEL::Exception);
+ std::vector<int> getGrpsNonEmptyLevels(const std::vector<std::string>& grps) const throw(INTERP_KERNEL::Exception);
+ std::vector<int> getGrpsNonEmptyLevelsExt(const std::vector<std::string>& grps) const throw(INTERP_KERNEL::Exception);
+ std::vector<int> getFamsNonEmptyLevels(const std::vector<std::string>& fams) const throw(INTERP_KERNEL::Exception);
+ std::vector<int> getFamsNonEmptyLevelsExt(const std::vector<std::string>& fams) const throw(INTERP_KERNEL::Exception);
DataArrayDouble *getCoords() const;
MEDCouplingUMesh *getGroup(int meshDimRelToMaxExt, const char *grp, bool renum=false) const throw(INTERP_KERNEL::Exception);
MEDCouplingUMesh *getGroups(int meshDimRelToMaxExt, const std::vector<std::string>& grps, bool renum=false) const throw(INTERP_KERNEL::Exception);
return ((const MEDCouplingUMesh *)_m_by_types)==0;
}
+bool MEDFileUMeshSplitL1::presenceOfOneFams(const std::vector<int>& ids) const
+{
+ const DataArrayInt *fam=_fam;
+ if(!fam)
+ return false;
+ return fam->presenceOfValue(ids);
+}
+
int MEDFileUMeshSplitL1::getMeshDimension() const
{
return _m_by_types->getMeshDimension();
void synchronizeTinyInfo(const MEDFileMesh& master) const;
void assignMesh(MEDCouplingUMesh *m, bool newOrOld) throw(INTERP_KERNEL::Exception);
bool empty() const;
+ bool presenceOfOneFams(const std::vector<int>& ids) const;
int getMeshDimension() const;
int getSize() const throw(INTERP_KERNEL::Exception);
MEDCouplingUMesh *getFamilyPart(const std::vector<int>& ids, bool renum) const;
const std::map<std::string,int>& getFamilyInfo() const;
const std::map<std::string, std::vector<std::string> >& getGroupInfo() const;
std::vector<std::string> getFamiliesOnGroup(const char *name) const throw(INTERP_KERNEL::Exception);
+ std::vector<std::string> getFamiliesOnGroups(const std::vector<std::string>& grps) const throw(INTERP_KERNEL::Exception);
std::vector<int> getFamiliesIdsOnGroup(const char *name) const throw(INTERP_KERNEL::Exception);
void setFamiliesOnGroup(const char *name, const std::vector<std::string>& fams) throw(INTERP_KERNEL::Exception);
void setFamiliesIdsOnGroup(const char *name, const std::vector<int>& famIds) throw(INTERP_KERNEL::Exception);
//
std::vector<int> getNonEmptyLevels() const;
std::vector<int> getNonEmptyLevelsExt() const;
+ std::vector<int> getGrpNonEmptyLevels(const char *grp) const throw(INTERP_KERNEL::Exception);
+ std::vector<int> getGrpNonEmptyLevelsExt(const char *grp) const throw(INTERP_KERNEL::Exception);
+ std::vector<int> getFamNonEmptyLevels(const char *fam) const throw(INTERP_KERNEL::Exception);
+ std::vector<int> getFamNonEmptyLevelsExt(const char *fam) const throw(INTERP_KERNEL::Exception);
+ std::vector<int> getGrpsNonEmptyLevels(const std::vector<std::string>& grps) const throw(INTERP_KERNEL::Exception);
+ std::vector<int> getGrpsNonEmptyLevelsExt(const std::vector<std::string>& grps) const throw(INTERP_KERNEL::Exception);
+ std::vector<int> getFamsNonEmptyLevels(const std::vector<std::string>& fams) const throw(INTERP_KERNEL::Exception);
+ std::vector<int> getFamsNonEmptyLevelsExt(const std::vector<std::string>& fams) const throw(INTERP_KERNEL::Exception);
DataArrayDouble *getCoords() const;
MEDCouplingUMesh *getGroup(int meshDimRelToMaxExt, const char *grp, bool renum=false) const throw(INTERP_KERNEL::Exception);
DataArrayInt *getGroupArr(int meshDimRelToMaxExt, const char *grp, bool renum=false) const throw(INTERP_KERNEL::Exception);
pass
m.setName(m2.getName())
m.setDescription(m2.getDescription())
+ #
+ self.assertEqual((-1,),m.getGrpNonEmptyLevels("A2A4"))
+ self.assertEqual((),m.getGrpNonEmptyLevels("A1"))
+ self.assertEqual((-2,),m.getGrpNonEmptyLevels("AP2"))
+ self.assertEqual((-1,-2),m.getGrpsNonEmptyLevels(["A2A4","AP2"]))
+ self.assertEqual((-1,),m.getFamNonEmptyLevels('A4A3____________________________'))
+ self.assertEqual((0,),m.getFamNonEmptyLevels('MESH____DALT3___DALLE___________'))
+ self.assertEqual((0,-1,),m.getFamsNonEmptyLevels(['MESH____DALT3___DALLE___________','A4A3____________________________']))
+ #
m.write(fileName,2)
pass