return ret;
}
+/*!
+ * This method expects that 'this' is allocated. If not an exception will be thrown.
+ * This method expect that the number of components is exactly equal to 1. If not an exception will be thrown.
+ * For each element in 'this' equal to 'oldValue' will take the value 'newValue'.
+ * @return number of elements impacted by the modification.
+ */
+int DataArrayInt::changeValue(int oldValue, int newValue) throw(INTERP_KERNEL::Exception)
+{
+ if(getNumberOfComponents()!=1)
+ throw INTERP_KERNEL::Exception("DataArrayInt::changeValue : the array must have only one component, you can call 'rearrange' method before !");
+ checkAllocated();
+ int *start=getPointer();
+ int *end=start+getNbOfElems();
+ int ret=0;
+ for(int *val=start;val!=end;val++)
+ {
+ if(*val==oldValue)
+ {
+ *val=newValue;
+ ret++;
+ }
+ }
+ return ret;
+}
+
DataArrayInt *DataArrayInt::getIdsEqualList(const std::vector<int>& vals) const throw(INTERP_KERNEL::Exception)
{
if(getNumberOfComponents()!=1)
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 int changeValue(int oldValue, int newValue) 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 getMaxValueInArray() const throw(INTERP_KERNEL::Exception);
return std::string("UnstructuredGrid");
}
+/// @cond INTERNAL
+
MEDCouplingUMesh *MEDCouplingUMesh::Intersect2DMeshes(const MEDCouplingUMesh *m1, const MEDCouplingUMesh *m2, double eps, DataArrayInt *&cellNb1, DataArrayInt *&cellNb2) throw(INTERP_KERNEL::Exception)
{
+ throw INTERP_KERNEL::Exception("MEDCouplingUMesh::Intersect2DMeshes : functionnality not finished yet ! Will come soon !");
std::vector< std::vector<int> > intersectEdge1, subDiv2;
MEDCouplingUMesh *m1Desc=0,*m2Desc=0;
DataArrayInt *desc1=0,*descIndx1=0,*revDesc1=0,*revDescIndx1=0,*desc2=0,*descIndx2=0,*revDesc2=0,*revDescIndx2=0;
return 0;
}
+/// @endcond
+
void MEDCouplingUMesh::BuildIntersecting2DCellsFromEdges(double eps, const MEDCouplingUMesh *m1, const std::vector<bool>& b1, const int *desc1, const int *descIndx1, const std::vector<std::vector<int> >& intesctEdges1,
const MEDCouplingUMesh *m2, const std::vector<bool>& b2, const int *desc2, const int *descIndx2, const std::vector<std::vector<int> >& intesctEdges2,
const std::vector<double>& addCoords,
MEDCOUPLING_EXPORT static bool IsPolygonWellOriented(bool isQuadratic, 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);
+/// @cond INTERNAL
MEDCOUPLING_EXPORT static MEDCouplingUMesh *Intersect2DMeshes(const MEDCouplingUMesh *m1, const MEDCouplingUMesh *m2, double eps, DataArrayInt *&cellNb1, DataArrayInt *&cellNb2) throw(INTERP_KERNEL::Exception);
+/// @endcond
private:
MEDCouplingUMesh();
MEDCouplingUMesh(const MEDCouplingUMesh& other, bool deepCpy);
_groups[newName]=cpy;
}
+void MEDFileMesh::changeFamilyId(int oldId, int newId) throw(INTERP_KERNEL::Exception)
+{
+ changeFamilyIdArr(oldId,newId);
+ std::map<std::string,int> fam2;
+ for(std::map<std::string,int>::const_iterator it=_families.begin();it!=_families.end();it++)
+ {
+ if((*it).second==oldId)
+ fam2[(*it).first]=newId;
+ else
+ fam2[(*it).first]=(*it).second;
+ }
+ _families=fam2;
+}
+
void MEDFileMesh::changeFamilyName(const char *oldName, const char *newName) throw(INTERP_KERNEL::Exception)
{
std::string oname(oldName);
(*it)->synchronizeTinyInfo(*this);
}
+void MEDFileUMesh::changeFamilyIdArr(int oldId, int newId) throw(INTERP_KERNEL::Exception)
+{
+ DataArrayInt *arr=_fam_coords;
+ if(arr)
+ arr->changeValue(oldId,newId);
+ for(std::vector< MEDCouplingAutoRefCountObjectPtr<MEDFileUMeshSplitL1> >::iterator it=_ms.begin();it!=_ms.end();it++)
+ {
+ MEDFileUMeshSplitL1 *sp=(*it);
+ if(sp)
+ {
+ sp->changeFamilyIdArr(oldId,newId);
+ }
+ }
+}
+
void MEDFileUMesh::computeRevNum() const
{
if((const DataArrayInt *)_num_coords)
throw e;
}
-
-
void MEDFileCMesh::loadCMeshFromFile(med_idt fid, const char *mName, int dt, int it) throw(INTERP_KERNEL::Exception)
{
MEDFileCMeshL2 loaderl2;
}
}
+void MEDFileCMesh::changeFamilyIdArr(int oldId, int newId) throw(INTERP_KERNEL::Exception)
+{
+ DataArrayInt *arr=_fam_nodes;
+ if(arr)
+ arr->changeValue(oldId,newId);
+ arr=_fam_cells;
+ if(arr)
+ arr->changeValue(oldId,newId);
+}
+
const MEDCouplingCMesh *MEDFileCMesh::getMesh() const
{
synchronizeTinyInfoOnLeaves();
void removeFamily(const char *name) throw(INTERP_KERNEL::Exception);
void changeGroupName(const char *oldName, const char *newName) throw(INTERP_KERNEL::Exception);
void changeFamilyName(const char *oldName, const char *newName) throw(INTERP_KERNEL::Exception);
+ void changeFamilyId(int oldId, int newId) throw(INTERP_KERNEL::Exception);
int getFamilyId(const char *name) const throw(INTERP_KERNEL::Exception);
int getMaxFamilyId() const throw(INTERP_KERNEL::Exception);
std::vector<int> getFamiliesIds(const std::vector<std::string>& famNames) const throw(INTERP_KERNEL::Exception);
virtual void synchronizeTinyInfoOnLeaves() const = 0;
void getFamilyRepr(std::ostream& oss) const;
virtual void appendFamilyEntries(const std::set<int>& famIds, const std::vector< std::vector<int> >& fidsOfGrps, const std::vector<std::string>& grpNames);
+ virtual void changeFamilyIdArr(int oldId, int newId) throw(INTERP_KERNEL::Exception) = 0;
static void TranslateFamilyIds(int offset, DataArrayInt *famArr, std::vector< std::vector<int> >& famIdsPerGrp);
protected:
int _order;
DataArrayDouble *checkMultiMesh(const std::vector<const MEDCouplingUMesh *>& ms) const throw(INTERP_KERNEL::Exception);
void computeRevNum() const;
void synchronizeTinyInfoOnLeaves() const;
+ void changeFamilyIdArr(int oldId, int newId) throw(INTERP_KERNEL::Exception);
private:
std::vector< MEDCouplingAutoRefCountObjectPtr<MEDFileUMeshSplitL1> > _ms;
MEDCouplingAutoRefCountObjectPtr<DataArrayDouble> _coords;
void synchronizeTinyInfoOnLeaves() const;
MEDFileCMesh(med_idt fid, const char *mName, int dt, int it) throw(INTERP_KERNEL::Exception);
void loadCMeshFromFile(med_idt fid, const char *mName, int dt, int it) throw(INTERP_KERNEL::Exception);
+ void changeFamilyIdArr(int oldId, int newId) throw(INTERP_KERNEL::Exception);
private:
MEDCouplingAutoRefCountObjectPtr<MEDCouplingCMesh> _cmesh;
MEDCouplingAutoRefCountObjectPtr<DataArrayInt> _fam_nodes;
}
}
+void MEDFileUMeshSplitL1::changeFamilyIdArr(int oldId, int newId) throw(INTERP_KERNEL::Exception)
+{
+ DataArrayInt *arr=_fam;
+ if(arr)
+ arr->changeValue(oldId,newId);
+}
+
void MEDFileUMeshSplitL1::setFamilyArr(DataArrayInt *famArr)
{
famArr->incrRef();
//
void setFamilyArr(DataArrayInt *famArr);
void setRenumArr(DataArrayInt *renumArr);
+ void changeFamilyIdArr(int oldId, int newId) throw(INTERP_KERNEL::Exception);
//
static void ClearNonDiscrAttributes(const MEDCouplingMesh *tmp);
static std::vector<int> GetNewFamiliesNumber(int nb, const std::map<std::string,int>& families);
void removeFamily(const char *name) throw(INTERP_KERNEL::Exception);
void changeGroupName(const char *oldName, const char *newName) throw(INTERP_KERNEL::Exception);
void changeFamilyName(const char *oldName, const char *newName) throw(INTERP_KERNEL::Exception);
+ void changeFamilyId(int oldId, int newId) throw(INTERP_KERNEL::Exception);
void setFamilyInfo(const std::map<std::string,int>& info);
void setGroupInfo(const std::map<std::string, std::vector<std::string> >&info);
int getFamilyId(const char *name) const throw(INTERP_KERNEL::Exception);
self.assertEqual(('Family_2', 'Family_4'),mm.getFamiliesOnGroup('g1'))
self.assertEqual(('Family_5',),mm.getFamiliesOnGroup('g2'))
self.assertEqual(('Family_4','Family_5',),mm.getFamiliesOnGroup('g3'))
+ mm.changeFamilyId(5,6)
+ g=mm.getGroupArr(0,"g3")
+ self.assertTrue(g.isEqual(g3));
+ g=mm.getGroupArr(0,"g2")
+ self.assertTrue(g.isEqual(g2));
+ g=mm.getGroupArr(0,"g1")
+ self.assertTrue(g.isEqual(g1));
pass
pass