_z_array->copyStringInfoFrom(*otherC->_z_array);
}
-bool MEDCouplingCMesh::isEqual(const MEDCouplingMesh *other, double prec) const
+bool MEDCouplingCMesh::isEqualIfNotWhy(const MEDCouplingMesh *other, double prec, std::string& reason) const throw(INTERP_KERNEL::Exception)
{
+ if(!other)
+ throw INTERP_KERNEL::Exception("MEDCouplingCMesh::isEqualIfNotWhy : input other pointer is null !");
const MEDCouplingCMesh *otherC=dynamic_cast<const MEDCouplingCMesh *>(other);
if(!otherC)
- return false;
- if(!MEDCouplingMesh::isEqual(other,prec))
+ {
+ reason="mesh given in input is not castable in MEDCouplingCMesh !";
+ return false;
+ }
+ if(!MEDCouplingMesh::isEqualIfNotWhy(other,prec,reason))
return false;
const DataArrayDouble *thisArr[3]={_x_array,_y_array,_z_array};
const DataArrayDouble *otherArr[3]={otherC->_x_array,otherC->_y_array,otherC->_z_array};
+ std::ostringstream oss; oss.precision(15);
for(int i=0;i<3;i++)
{
if((thisArr[i]!=0 && otherArr[i]==0) || (thisArr[i]==0 && otherArr[i]!=0))
- return false;
- if(thisArr[i])
- if(!thisArr[i]->isEqual(*otherArr[i],prec))
+ {
+ oss << "Only one CMesh between the two this and other has its coordinates of rank" << i << " defined !";
+ reason=oss.str();
return false;
+ }
+ if(thisArr[i])
+ if(!thisArr[i]->isEqualIfNotWhy(*otherArr[i],prec,reason))
+ {
+ oss << "Coordinates DataArrayDouble of rank #" << i << " differ :";
+ reason.insert(0,oss.str());
+ return false;
+ }
}
return true;
}
void updateTime() const;
MEDCouplingMeshType getType() const { return CARTESIAN; }
void copyTinyStringsFrom(const MEDCouplingMesh *other) throw(INTERP_KERNEL::Exception);
- bool isEqual(const MEDCouplingMesh *other, double prec) const;
+ bool isEqualIfNotWhy(const MEDCouplingMesh *other, double prec, std::string& reason) const throw(INTERP_KERNEL::Exception);
bool isEqualWithoutConsideringStr(const MEDCouplingMesh *other, double prec) const;
void checkDeepEquivalWith(const MEDCouplingMesh *other, int cellCompPol, double prec,
DataArrayInt *&cellCor, DataArrayInt *&nodeCor) const throw(INTERP_KERNEL::Exception);
return new MEDCouplingExtrudedMesh(*this,recDeepCpy);
}
-bool MEDCouplingExtrudedMesh::isEqual(const MEDCouplingMesh *other, double prec) const
+bool MEDCouplingExtrudedMesh::isEqualIfNotWhy(const MEDCouplingMesh *other, double prec, std::string& reason) const throw(INTERP_KERNEL::Exception)
{
+ if(!other)
+ throw INTERP_KERNEL::Exception("MEDCouplingExtrudedMesh::isEqualIfNotWhy : input other pointer is null !");
const MEDCouplingExtrudedMesh *otherC=dynamic_cast<const MEDCouplingExtrudedMesh *>(other);
+ std::ostringstream oss;
if(!otherC)
+ {
+ reason="mesh given in input is not castable in MEDCouplingExtrudedMesh !";
+ return false;
+ }
+ if(!MEDCouplingMesh::isEqualIfNotWhy(other,prec,reason))
return false;
- if(!MEDCouplingMesh::isEqual(other,prec))
- return false;
- if(!_mesh2D->isEqual(otherC->_mesh2D,prec))
- return false;
- if(!_mesh1D->isEqual(otherC->_mesh1D,prec))
- return false;
- if(!_mesh3D_ids->isEqual(*otherC->_mesh3D_ids))
- return false;
+ if(!_mesh2D->isEqualIfNotWhy(otherC->_mesh2D,prec,reason))
+ {
+ reason.insert(0,"Mesh2D unstructured meshes differ : ");
+ return false;
+ }
+ if(!_mesh1D->isEqualIfNotWhy(otherC->_mesh1D,prec,reason))
+ {
+ reason.insert(0,"Mesh1D unstructured meshes differ : ");
+ return false;
+ }
+ if(!_mesh3D_ids->isEqualIfNotWhy(*otherC->_mesh3D_ids,reason))
+ {
+ reason.insert(0,"Mesh3D ids DataArrayInt instances differ : ");
+ return false;
+ }
if(_cell_2D_id!=otherC->_cell_2D_id)
- return false;
+ {
+ oss << "Cell 2D id of the two extruded mesh differ : this = " << _cell_2D_id << " other = " << otherC->_cell_2D_id;
+ reason=oss.str();
+ return false;
+ }
return true;
}
int getMeshDimension() const;
MEDCouplingMesh *deepCpy() const;
MEDCouplingExtrudedMesh *clone(bool recDeepCpy) const;
- bool isEqual(const MEDCouplingMesh *other, double prec) const;
+ bool isEqualIfNotWhy(const MEDCouplingMesh *other, double prec, std::string& reason) const throw(INTERP_KERNEL::Exception);
bool isEqualWithoutConsideringStr(const MEDCouplingMesh *other, double prec) const;
void checkDeepEquivalWith(const MEDCouplingMesh *other, int cellCompPol, double prec,
DataArrayInt *&cellCor, DataArrayInt *&nodeCor) const throw(INTERP_KERNEL::Exception);
#include "MEDCouplingMesh.hxx"
#include "MEDCouplingFieldDiscretization.hxx"
+#include <sstream>
+
using namespace ParaMEDMEM;
-bool MEDCouplingField::isEqual(const MEDCouplingField *other, double meshPrec, double valsPrec) const
+bool MEDCouplingField::isEqualIfNotWhy(const MEDCouplingField *other, double meshPrec, double valsPrec, std::string& reason) const throw(INTERP_KERNEL::Exception)
{
+ if(!other)
+ throw INTERP_KERNEL::Exception("MEDCouplingField::isEqualIfNotWhy : other instance is NULL !");
+ std::ostringstream oss; oss.precision(15);
if(_name!=other->_name)
- return false;
+ {
+ oss << "Field names differ : this name = \"" << _name << "\" and other name = \"" << other->_name << "\" !";
+ reason=oss.str();
+ return false;
+ }
if(_desc!=other->_desc)
- return false;
+ {
+ oss << "Field descriptions differ : this description = \"" << _desc << "\" and other description = \"" << other->_desc << "\" !";
+ reason=oss.str();
+ return false;
+ }
if(_nature!=other->_nature)
- return false;
- if(!_type->isEqual(other->_type,valsPrec))
- return false;
+ {
+ oss << "Field nature differ : this nature = \"" << MEDCouplingNatureOfField::getRepr(_nature) << "\" and other nature = \"" << MEDCouplingNatureOfField::getRepr(other->_nature) << "\" !";
+ reason=oss.str();
+ return false;
+ }
+ if(!_type->isEqualIfNotWhy(other->_type,valsPrec,reason))
+ {
+ reason.insert(0,"Spatial discretizations differ :");
+ return false;
+ }
if(_mesh==0 && other->_mesh==0)
return true;
if(_mesh==0 || other->_mesh==0)
- return false;
+ {
+ reason="Only one field between the two this and other has its underlying mesh defined !";
+ return false;
+ }
if(_mesh==other->_mesh)
return true;
- return _mesh->isEqual(other->_mesh,meshPrec);
+ bool ret=_mesh->isEqualIfNotWhy(other->_mesh,meshPrec,reason);
+ if(!ret)
+ reason.insert(0,"Underlying meshes of fields differ for the following reason : ");
+ return ret;
+}
+
+bool MEDCouplingField::isEqual(const MEDCouplingField *other, double meshPrec, double valsPrec) const
+{
+ std::string tmp;
+ return isEqualIfNotWhy(other,meshPrec,valsPrec,tmp);
}
bool MEDCouplingField::isEqualWithoutConsideringStr(const MEDCouplingField *other, double meshPrec, double valsPrec) const
virtual void checkCoherency() const throw(INTERP_KERNEL::Exception) = 0;
virtual bool areCompatibleForMerge(const MEDCouplingField *other) const;
virtual bool areStrictlyCompatible(const MEDCouplingField *other) const;
+ virtual bool isEqualIfNotWhy(const MEDCouplingField *other, double meshPrec, double valsPrec, std::string& reason) const throw(INTERP_KERNEL::Exception);
virtual bool isEqual(const MEDCouplingField *other, double meshPrec, double valsPrec) const;
virtual bool isEqualWithoutConsideringStr(const MEDCouplingField *other, double meshPrec, double valsPrec) const;
void setMesh(const ParaMEDMEM::MEDCouplingMesh *mesh);
throw INTERP_KERNEL::Exception("Representation does not match with any field discretization !");
}
+bool MEDCouplingFieldDiscretization::isEqual(const MEDCouplingFieldDiscretization *other, double eps) const
+{
+ std::string reason;
+ return isEqualIfNotWhy(other,eps,reason);
+}
+
bool MEDCouplingFieldDiscretization::isEqualWithoutConsideringStr(const MEDCouplingFieldDiscretization *other, double eps) const
{
return isEqual(other,eps);
return REPR;
}
-bool MEDCouplingFieldDiscretizationP0::isEqual(const MEDCouplingFieldDiscretization *other, double eps) const
+bool MEDCouplingFieldDiscretizationP0::isEqualIfNotWhy(const MEDCouplingFieldDiscretization *other, double eps, std::string& reason) const
{
const MEDCouplingFieldDiscretizationP0 *otherC=dynamic_cast<const MEDCouplingFieldDiscretizationP0 *>(other);
- return otherC!=0;
+ bool ret=otherC!=0;
+ if(!ret)
+ reason="Spatial discrtization of this is ON_CELLS, which is not the case of other.";
+ return ret;
}
int MEDCouplingFieldDiscretizationP0::getNumberOfTuples(const MEDCouplingMesh *mesh) const
return REPR;
}
-bool MEDCouplingFieldDiscretizationP1::isEqual(const MEDCouplingFieldDiscretization *other, double eps) const
+bool MEDCouplingFieldDiscretizationP1::isEqualIfNotWhy(const MEDCouplingFieldDiscretization *other, double eps, std::string& reason) const
{
const MEDCouplingFieldDiscretizationP1 *otherC=dynamic_cast<const MEDCouplingFieldDiscretizationP1 *>(other);
- return otherC!=0;
+ bool ret=otherC!=0;
+ if(!ret)
+ reason="Spatial discrtization of this is ON_NODES, which is not the case of other.";
+ return ret;
}
/*!
throw INTERP_KERNEL::Exception("MEDCouplingFieldDiscretizationPerCell has a discretization per cell but it's not matching the underlying mesh !");
}
-bool MEDCouplingFieldDiscretizationPerCell::isEqual(const MEDCouplingFieldDiscretization *other, double eps) const
+bool MEDCouplingFieldDiscretizationPerCell::isEqualIfNotWhy(const MEDCouplingFieldDiscretization *other, double eps, std::string& reason) const
{
const MEDCouplingFieldDiscretizationPerCell *otherC=dynamic_cast<const MEDCouplingFieldDiscretizationPerCell *>(other);
if(!otherC)
- return false;
+ {
+ reason="Spatial discrtization of this is ON_GAUSS, which is not the case of other.";
+ return false;
+ }
if(_discr_per_cell==0)
return otherC->_discr_per_cell==0;
if(otherC->_discr_per_cell==0)
return false;
- return _discr_per_cell->isEqual(*otherC->_discr_per_cell);
+ bool ret=_discr_per_cell->isEqualIfNotWhy(*otherC->_discr_per_cell,reason);
+ if(!ret)
+ reason.insert(0,"Field discretization per cell DataArrayInt given the discid per cell :");
+ return ret;
}
bool MEDCouplingFieldDiscretizationPerCell::isEqualWithoutConsideringStr(const MEDCouplingFieldDiscretization *other, double eps) const
return TYPE;
}
-bool MEDCouplingFieldDiscretizationGauss::isEqual(const MEDCouplingFieldDiscretization *other, double eps) const
+bool MEDCouplingFieldDiscretizationGauss::isEqualIfNotWhy(const MEDCouplingFieldDiscretization *other, double eps, std::string& reason) const
{
const MEDCouplingFieldDiscretizationGauss *otherC=dynamic_cast<const MEDCouplingFieldDiscretizationGauss *>(other);
if(!otherC)
- return false;
- if(!MEDCouplingFieldDiscretizationPerCell::isEqual(other,eps))
+ {
+ reason="Spatial discrtization of this is ON_GAUSS, which is not the case of other.";
+ return false;
+ }
+ if(!MEDCouplingFieldDiscretizationPerCell::isEqualIfNotWhy(other,eps,reason))
return false;
if(_loc.size()!=otherC->_loc.size())
- return false;
+ {
+ reason="Gauss spatial discretization : localization sizes differ";
+ return false;
+ }
std::size_t sz=_loc.size();
for(std::size_t i=0;i<sz;i++)
if(!_loc[i].isEqual(otherC->_loc[i],eps))
- return false;
+ {
+ std::ostringstream oss; oss << "Gauss spatial discretization : Localization #" << i << " differ from this to other.";
+ reason=oss.str();
+ return false;
+ }
return true;
}
return REPR;
}
-bool MEDCouplingFieldDiscretizationGaussNE::isEqual(const MEDCouplingFieldDiscretization *other, double eps) const
+bool MEDCouplingFieldDiscretizationGaussNE::isEqualIfNotWhy(const MEDCouplingFieldDiscretization *other, double eps, std::string& reason) const
{
const MEDCouplingFieldDiscretizationGaussNE *otherC=dynamic_cast<const MEDCouplingFieldDiscretizationGaussNE *>(other);
- return otherC!=0;
+ bool ret=otherC!=0;
+ if(!ret)
+ reason="Spatial discrtization of this is ON_GAUSS_NE, which is not the case of other.";
+ return ret;
}
int MEDCouplingFieldDiscretizationGaussNE::getNumberOfTuples(const MEDCouplingMesh *mesh) const
void updateTime() const;
static TypeOfField getTypeOfFieldFromStringRepr(const char *repr) throw(INTERP_KERNEL::Exception);
virtual TypeOfField getEnum() const = 0;
- virtual bool isEqual(const MEDCouplingFieldDiscretization *other, double eps) const = 0;
+ virtual bool isEqual(const MEDCouplingFieldDiscretization *other, double eps) const;
+ virtual bool isEqualIfNotWhy(const MEDCouplingFieldDiscretization *other, double eps, std::string& reason) const = 0;
virtual bool isEqualWithoutConsideringStr(const MEDCouplingFieldDiscretization *other, double eps) const;
virtual MEDCouplingFieldDiscretization *clone() const = 0;
virtual std::string getStringRepr() const = 0;
MEDCouplingFieldDiscretization *clone() const;
std::string getStringRepr() const;
const char *getRepr() const;
- bool isEqual(const MEDCouplingFieldDiscretization *other, double eps) const;
+ bool isEqualIfNotWhy(const MEDCouplingFieldDiscretization *other, double eps, std::string& reason) const;
int getNumberOfTuples(const MEDCouplingMesh *mesh) const;
int getNumberOfMeshPlaces(const MEDCouplingMesh *mesh) const;
DataArrayInt *getOffsetArr(const MEDCouplingMesh *mesh) const;
MEDCouplingFieldDiscretization *clone() const;
std::string getStringRepr() const;
const char *getRepr() const;
- bool isEqual(const MEDCouplingFieldDiscretization *other, double eps) const;
+ bool isEqualIfNotWhy(const MEDCouplingFieldDiscretization *other, double eps, std::string& reason) const;
int getNumberOfTuples(const MEDCouplingMesh *mesh) const;
int getNumberOfMeshPlaces(const MEDCouplingMesh *mesh) const;
DataArrayInt *getOffsetArr(const MEDCouplingMesh *mesh) const;
~MEDCouplingFieldDiscretizationPerCell();
void updateTime() const;
void checkCoherencyBetween(const MEDCouplingMesh *mesh, const DataArrayDouble *da) const throw(INTERP_KERNEL::Exception);
- bool isEqual(const MEDCouplingFieldDiscretization *other, double eps) const;
+ bool isEqualIfNotWhy(const MEDCouplingFieldDiscretization *other, double eps, std::string& reason) const;
bool isEqualWithoutConsideringStr(const MEDCouplingFieldDiscretization *other, double eps) const;
void renumberCells(const int *old2NewBg, bool check) throw(INTERP_KERNEL::Exception);
void checkNoOrphanCells() const throw(INTERP_KERNEL::Exception);
public:
MEDCouplingFieldDiscretizationGauss();
TypeOfField getEnum() const;
- bool isEqual(const MEDCouplingFieldDiscretization *other, double eps) const;
+ bool isEqualIfNotWhy(const MEDCouplingFieldDiscretization *other, double eps, std::string& reason) const;
bool isEqualWithoutConsideringStr(const MEDCouplingFieldDiscretization *other, double eps) const;
MEDCouplingFieldDiscretization *clone() const;
std::string getStringRepr() const;
MEDCouplingFieldDiscretization *clone() const;
std::string getStringRepr() const;
const char *getRepr() const;
- bool isEqual(const MEDCouplingFieldDiscretization *other, double eps) const;
+ bool isEqualIfNotWhy(const MEDCouplingFieldDiscretization *other, double eps, std::string& reason) const;
int getNumberOfTuples(const MEDCouplingMesh *mesh) const;
int getNumberOfMeshPlaces(const MEDCouplingMesh *mesh) const;
DataArrayInt *getOffsetArr(const MEDCouplingMesh *mesh) const;
return ret.str();
}
-bool MEDCouplingFieldDouble::isEqual(const MEDCouplingField *other, double meshPrec, double valsPrec) const
+bool MEDCouplingFieldDouble::isEqualIfNotWhy(const MEDCouplingField *other, double meshPrec, double valsPrec, std::string& reason) const throw(INTERP_KERNEL::Exception)
{
+ if(!other)
+ throw INTERP_KERNEL::Exception("MEDCouplingFieldDouble::isEqualIfNotWhy : other instance is NULL !");
const MEDCouplingFieldDouble *otherC=dynamic_cast<const MEDCouplingFieldDouble *>(other);
if(!otherC)
+ {
+ reason="field given in input is not castable in MEDCouplingFieldDouble !";
+ return false;
+ }
+ if(!MEDCouplingField::isEqualIfNotWhy(other,meshPrec,valsPrec,reason))
return false;
- if(!MEDCouplingField::isEqual(other,meshPrec,valsPrec))
- return false;
- if(!_time_discr->isEqual(otherC->_time_discr,valsPrec))
- return false;
+ if(!_time_discr->isEqualIfNotWhy(otherC->_time_discr,valsPrec,reason))
+ {
+ reason.insert(0,"In FieldDouble time discretizations differ :");
+ return false;
+ }
return true;
}
*/
bool MEDCouplingFieldDouble::areStrictlyCompatible(const MEDCouplingField *other) const
{
+ std::string tmp;
if(!MEDCouplingField::areStrictlyCompatible(other))
return false;
const MEDCouplingFieldDouble *otherC=dynamic_cast<const MEDCouplingFieldDouble *>(other);
if(!otherC)
return false;
- if(!_time_discr->areStrictlyCompatible(otherC->_time_discr))
+ if(!_time_discr->areStrictlyCompatible(otherC->_time_discr,tmp))
return false;
return true;
}
void copyTinyAttrFrom(const MEDCouplingFieldDouble *other) throw(INTERP_KERNEL::Exception);
std::string simpleRepr() const;
std::string advancedRepr() const;
- bool isEqual(const MEDCouplingField *other, double meshPrec, double valsPrec) const;
+ bool isEqualIfNotWhy(const MEDCouplingField *other, double meshPrec, double valsPrec, std::string& reason) const throw(INTERP_KERNEL::Exception);
bool isEqualWithoutConsideringStr(const MEDCouplingField *other, double meshPrec, double valsPrec) const;
bool areCompatibleForMerge(const MEDCouplingField *other) const;
bool areStrictlyCompatible(const MEDCouplingField *other) const;
setInfoOnComponent(compoIds[i],other.getInfoOnComponent((int)i).c_str());
}
-bool DataArray::areInfoEquals(const DataArray& other) const
+bool DataArray::areInfoEqualsIfNotWhy(const DataArray& other, std::string& reason) const
{
+ std::ostringstream oss;
if(_nb_of_tuples!=other._nb_of_tuples)
- return false;
+ {
+ oss << "Number of tuples of DataArray mismatch : this number of tuples=" << _nb_of_tuples << " other number of tuples=" << other._nb_of_tuples;
+ reason=oss.str();
+ return false;
+ }
if(_name!=other._name)
- return false;
- return _info_on_compo==other._info_on_compo;
+ {
+ oss << "Names DataArray mismatch : this name=\"" << _name << " other name=\"" << other._name << "\" !";
+ reason=oss.str();
+ return false;
+ }
+ if(_info_on_compo!=other._info_on_compo)
+ {
+ oss << "Components DataArray mismatch : \nThis components=";
+ for(std::vector<std::string>::const_iterator it=_info_on_compo.begin();it!=_info_on_compo.end();it++)
+ oss << "\"" << *it << "\",";
+ oss << "\nOther components=";
+ for(std::vector<std::string>::const_iterator it=other._info_on_compo.begin();it!=other._info_on_compo.end();it++)
+ oss << "\"" << *it << "\",";
+ reason=oss.str();
+ return false;
+ }
+ return true;
+}
+
+bool DataArray::areInfoEquals(const DataArray& other) const
+{
+ std::string tmp;
+ return areInfoEqualsIfNotWhy(other,tmp);
}
void DataArray::reprWithoutNameStream(std::ostream& stream) const
_mem.reprZip(getNumberOfComponents(),stream);
}
-bool DataArrayDouble::isEqual(const DataArrayDouble& other, double prec) const
+bool DataArrayDouble::isEqualIfNotWhy(const DataArrayDouble& other, double prec, std::string& reason) const
{
- if(!areInfoEquals(other))
+ if(!areInfoEqualsIfNotWhy(other,reason))
return false;
- return _mem.isEqual(other._mem,prec);
+ return _mem.isEqual(other._mem,prec,reason);
+}
+
+bool DataArrayDouble::isEqual(const DataArrayDouble& other, double prec) const
+{
+ std::string tmp;
+ return isEqualIfNotWhy(other,prec,tmp);
}
bool DataArrayDouble::isEqualWithoutConsideringStr(const DataArrayDouble& other, double prec) const
{
- return _mem.isEqual(other._mem,prec);
+ std::string tmp;
+ return _mem.isEqual(other._mem,prec,tmp);
}
void DataArrayDouble::reAlloc(int nbOfTuples) throw(INTERP_KERNEL::Exception)
return ret;
}
-bool DataArrayInt::isEqual(const DataArrayInt& other) const
+bool DataArrayInt::isEqualIfNotWhy(const DataArrayInt& other, std::string& reason) const
{
- if(!areInfoEquals(other))
+ if(!areInfoEqualsIfNotWhy(other,reason))
return false;
- return _mem.isEqual(other._mem,0);
+ return _mem.isEqual(other._mem,0,reason);
+}
+
+bool DataArrayInt::isEqual(const DataArrayInt& other) const
+{
+ std::string tmp;
+ return isEqualIfNotWhy(other,tmp);
}
bool DataArrayInt::isEqualWithoutConsideringStr(const DataArrayInt& other) const
{
- return _mem.isEqual(other._mem,0);
+ std::string tmp;
+ return _mem.isEqual(other._mem,0,tmp);
}
bool DataArrayInt::isEqualWithoutConsideringStrAndOrder(const DataArrayInt& other) const throw(INTERP_KERNEL::Exception)
MemArray<T> &operator=(const MemArray<T>& other);
T operator[](int id) const { return _pointer.getConstPointer()[id]; }
T& operator[](int id) { return _pointer.getPointer()[id]; }
- bool isEqual(const MemArray<T>& other, T prec) const;
+ bool isEqual(const MemArray<T>& other, T prec, std::string& reason) const;
void repr(int sl, std::ostream& stream) const;
void reprZip(int sl, std::ostream& stream) const;
void fillWithValue(const T& val);
MEDCOUPLING_EXPORT void copyStringInfoFrom(const DataArray& other) throw(INTERP_KERNEL::Exception);
MEDCOUPLING_EXPORT void copyPartOfStringInfoFrom(const DataArray& other, const std::vector<int>& compoIds) throw(INTERP_KERNEL::Exception);
MEDCOUPLING_EXPORT void copyPartOfStringInfoFrom2(const std::vector<int>& compoIds, const DataArray& other) throw(INTERP_KERNEL::Exception);
+ MEDCOUPLING_EXPORT bool areInfoEqualsIfNotWhy(const DataArray& other, std::string& reason) const;
MEDCOUPLING_EXPORT bool areInfoEquals(const DataArray& other) const;
MEDCOUPLING_EXPORT void reprWithoutNameStream(std::ostream& stream) const;
MEDCOUPLING_EXPORT std::string getName() const { return _name; }
MEDCOUPLING_EXPORT void reprWithoutNameStream(std::ostream& stream) const;
MEDCOUPLING_EXPORT void reprZipWithoutNameStream(std::ostream& stream) const;
MEDCOUPLING_EXPORT bool isEqual(const DataArrayDouble& other, double prec) const;
+ MEDCOUPLING_EXPORT bool isEqualIfNotWhy(const DataArrayDouble& other, double prec, std::string& reason) const;
MEDCOUPLING_EXPORT bool isEqualWithoutConsideringStr(const DataArrayDouble& other, double prec) const;
//!alloc or useArray should have been called before.
MEDCOUPLING_EXPORT void reAlloc(int nbOfTuples) throw(INTERP_KERNEL::Exception);
MEDCOUPLING_EXPORT void alloc(int nbOfTuple, int nbOfCompo) throw(INTERP_KERNEL::Exception);
MEDCOUPLING_EXPORT void allocIfNecessary(int nbOfTuple, int nbOfCompo);
MEDCOUPLING_EXPORT bool isEqual(const DataArrayInt& other) const;
+ MEDCOUPLING_EXPORT bool isEqualIfNotWhy(const DataArrayInt& other, std::string& reason) 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);
}
template<class T>
- bool MemArray<T>::isEqual(const MemArray<T>& other, T prec) const
+ bool MemArray<T>::isEqual(const MemArray<T>& other, T prec, std::string& reason) const
{
+ std::ostringstream oss; oss.precision(15);
if(_nb_of_elem!=other._nb_of_elem)
- return false;
+ {
+ oss << "Number of elements in coarse data of DataArray mismatch : this=" << _nb_of_elem << " other=" << other._nb_of_elem;
+ reason=oss.str();
+ return false;
+ }
const T *pt1=_pointer.getConstPointer();
const T *pt2=other._pointer.getConstPointer();
if(pt1==0 && pt2==0)
return true;
if(pt1==0 || pt2==0)
- return false;
+ {
+ oss << "coarse data pointer is defined for only one DataArray instance !";
+ reason=oss.str();
+ return false;
+ }
if(pt1==pt2)
return true;
for(int i=0;i<_nb_of_elem;i++)
if(pt1[i]-pt2[i]<-prec || (pt1[i]-pt2[i])>prec)
- return false;
+ {
+ oss << "The content of data differs at pos #" << i << " of coarse data ! this[i]=" << pt1[i] << " other[i]=" << pt2[i];
+ reason=oss.str();
+ return false;
+ }
return true;
}
return getType()==CARTESIAN;
}
-bool MEDCouplingMesh::isEqual(const MEDCouplingMesh *other, double prec) const
+bool MEDCouplingMesh::isEqualIfNotWhy(const MEDCouplingMesh *other, double prec, std::string& reason) const throw(INTERP_KERNEL::Exception)
{
- return _name==other->_name && _description==other->_description && _iteration==other->_iteration
- && _order==other->_order && _time_unit==other->_time_unit && fabs(_time-other->_time)<1e-12;
+ if(!other)
+ throw INTERP_KERNEL::Exception("MEDCouplingMesh::isEqualIfNotWhy : other instance is NULL !");
+ std::ostringstream oss; oss.precision(15);
+ if(_name!=other->_name)
+ {
+ oss << "Mesh names differ : this name = \"" << _name << "\" and other name = \"" << other->_name << "\" !";
+ reason=oss.str();
+ return false;
+ }
+ if(_description!=other->_description)
+ {
+ oss << "Mesh descriptions differ : this description = \"" << _description << "\" and other description = \"" << other->_description << "\" !";
+ reason=oss.str();
+ return false;
+ }
+ if(_iteration!=other->_iteration)
+ {
+ oss << "Mesh iterations differ : this iteration = \"" << _iteration << "\" and other iteration = \"" << other->_iteration << "\" !";
+ reason=oss.str();
+ return false;
+ }
+ if(_order!=other->_order)
+ {
+ oss << "Mesh orders differ : this order = \"" << _order << "\" and other order = \"" << other->_order << "\" !";
+ reason=oss.str();
+ return false;
+ }
+ if(_time_unit!=other->_time_unit)
+ {
+ oss << "Mesh time units differ : this time unit = \"" << _time_unit << "\" and other time unit = \"" << other->_time_unit << "\" !";
+ reason=oss.str();
+ return false;
+ }
+ if(fabs(_time-other->_time)>=1e-12)
+ {
+ oss << "Mesh times differ : this time = \"" << _time << "\" and other time = \"" << other->_time << "\" !";
+ reason=oss.str();
+ return false;
+ }
+ return true;
+}
+
+bool MEDCouplingMesh::isEqual(const MEDCouplingMesh *other, double prec) const throw(INTERP_KERNEL::Exception)
+{
+ std::string tmp;
+ return isEqualIfNotWhy(other,prec,tmp);
}
/*!
virtual void copyTinyStringsFrom(const MEDCouplingMesh *other) throw(INTERP_KERNEL::Exception);
virtual void copyTinyInfoFrom(const MEDCouplingMesh *other) throw(INTERP_KERNEL::Exception);
// comparison methods
- virtual bool isEqual(const MEDCouplingMesh *other, double prec) const;
+ virtual bool isEqualIfNotWhy(const MEDCouplingMesh *other, double prec, std::string& reason) const throw(INTERP_KERNEL::Exception);
+ virtual bool isEqual(const MEDCouplingMesh *other, double prec) const throw(INTERP_KERNEL::Exception);
virtual bool isEqualWithoutConsideringStr(const MEDCouplingMesh *other, double prec) const = 0;
virtual void checkDeepEquivalWith(const MEDCouplingMesh *other, int cellCompPol, double prec,
DataArrayInt *&cellCor, DataArrayInt *&nodeCor) const throw(INTERP_KERNEL::Exception) = 0;
_coords->copyStringInfoFrom(*otherC->_coords);
}
-bool MEDCouplingPointSet::isEqual(const MEDCouplingMesh *other, double prec) const
+bool MEDCouplingPointSet::isEqualIfNotWhy(const MEDCouplingMesh *other, double prec, std::string& reason) const throw(INTERP_KERNEL::Exception)
{
+ if(!other)
+ throw INTERP_KERNEL::Exception("MEDCouplingPointSet::isEqualIfNotWhy : null mesh instance in input !");
const MEDCouplingPointSet *otherC=dynamic_cast<const MEDCouplingPointSet *>(other);
if(!otherC)
+ {
+ reason="mesh given in input is not castable in MEDCouplingPointSet !";
+ return false;
+ }
+ if(!MEDCouplingMesh::isEqualIfNotWhy(other,prec,reason))
return false;
- if(!MEDCouplingMesh::isEqual(other,prec))
- return false;
- if(!areCoordsEqual(*otherC,prec))
+ if(!areCoordsEqualIfNotWhy(*otherC,prec,reason))
return false;
return true;
}
return true;
}
-bool MEDCouplingPointSet::areCoordsEqual(const MEDCouplingPointSet& other, double prec) const
+bool MEDCouplingPointSet::areCoordsEqualIfNotWhy(const MEDCouplingPointSet& other, double prec, std::string& reason) const
{
if(_coords==0 && other._coords==0)
return true;
if(_coords==0 || other._coords==0)
- return false;
+ {
+ reason="Only one PointSet between the two this and other has coordinate defined !";
+ return false;
+ }
if(_coords==other._coords)
return true;
- return _coords->isEqual(*other._coords,prec);
+ bool ret=_coords->isEqualIfNotWhy(*other._coords,prec,reason);
+ if(!ret)
+ reason.insert(0,"Coordinates DataArray do not match : ");
+ return ret;
+}
+
+bool MEDCouplingPointSet::areCoordsEqual(const MEDCouplingPointSet& other, double prec) const
+{
+ std::string tmp;
+ return areCoordsEqualIfNotWhy(other,prec,tmp);
}
bool MEDCouplingPointSet::areCoordsEqualWithoutConsideringStr(const MEDCouplingPointSet& other, double prec) const
DataArrayDouble *getCoords() { return _coords; }
DataArrayDouble *getCoordinatesAndOwner() const;
void copyTinyStringsFrom(const MEDCouplingMesh *other) throw(INTERP_KERNEL::Exception);
- bool isEqual(const MEDCouplingMesh *other, double prec) const;
+ bool isEqualIfNotWhy(const MEDCouplingMesh *other, double prec, std::string& reason) const throw(INTERP_KERNEL::Exception);
bool isEqualWithoutConsideringStr(const MEDCouplingMesh *other, double prec) const;
+ bool areCoordsEqualIfNotWhy(const MEDCouplingPointSet& other, double prec, std::string& reason) const;
bool areCoordsEqual(const MEDCouplingPointSet& other, double prec) const;
bool areCoordsEqualWithoutConsideringStr(const MEDCouplingPointSet& other, double prec) const;
virtual DataArrayInt *mergeNodes(double precision, bool& areNodesMerged, int& newNbOfNodes) = 0;
return true;
}
-bool MEDCouplingTimeDiscretization::areStrictlyCompatible(const MEDCouplingTimeDiscretization *other) const
+bool MEDCouplingTimeDiscretization::areStrictlyCompatible(const MEDCouplingTimeDiscretization *other, std::string& reason) const
{
+ std::ostringstream oss; oss.precision(15);
if(_time_unit!=other->_time_unit)
- return false;
+ {
+ oss << "Field discretizations differ : this time unit = \"" << _time_unit << "\" and other time unit = \"" << other->_time_unit << "\" !";
+ reason=oss.str();
+ return false;
+ }
if(std::fabs(_time_tolerance-other->_time_tolerance)>1.e-16)
- return false;
+ {
+ oss << "Field discretizations differ : this time tolerance = \"" << _time_tolerance << "\" and other time tolerance = \"" << other->_time_tolerance << "\" !";
+ reason=oss.str();
+ return false;
+ }
if(_array==0 && other->_array==0)
return true;
if(_array==0 || other->_array==0)
- return false;
+ {
+ reason="Field discretizations differ : Only one timediscretization between the two this and other has a DataArrayDouble for values defined";
+ return false;
+ }
if(_array->getNumberOfComponents()!=other->_array->getNumberOfComponents())
return false;
if(_array->getNumberOfTuples()!=other->_array->getNumberOfTuples())
return true;
}
-bool MEDCouplingTimeDiscretization::isEqual(const MEDCouplingTimeDiscretization *other, double prec) const
+bool MEDCouplingTimeDiscretization::isEqualIfNotWhy(const MEDCouplingTimeDiscretization *other, double prec, std::string& reason) const
{
- if(!areStrictlyCompatible(other))
+ if(!areStrictlyCompatible(other,reason))
return false;
if(_array==other->_array)
return true;
- return _array->isEqual(*other->_array,prec);
+ return _array->isEqualIfNotWhy(*other->_array,prec,reason);
+}
+
+bool MEDCouplingTimeDiscretization::isEqual(const MEDCouplingTimeDiscretization *other, double prec) const
+{
+ std::string reason;
+ return isEqualIfNotWhy(other,prec,reason);
}
bool MEDCouplingTimeDiscretization::isEqualWithoutConsideringStr(const MEDCouplingTimeDiscretization *other, double prec) const
{
- if(!areStrictlyCompatible(other))
+ std::string tmp;
+ if(!areStrictlyCompatible(other,tmp))
return false;
if(_array==other->_array)
return true;
return otherC!=0;
}
-bool MEDCouplingNoTimeLabel::areStrictlyCompatible(const MEDCouplingTimeDiscretization *other) const
+bool MEDCouplingNoTimeLabel::areStrictlyCompatible(const MEDCouplingTimeDiscretization *other, std::string& reason) const
{
- if(!MEDCouplingTimeDiscretization::areStrictlyCompatible(other))
+ if(!MEDCouplingTimeDiscretization::areStrictlyCompatible(other,reason))
return false;
const MEDCouplingNoTimeLabel *otherC=dynamic_cast<const MEDCouplingNoTimeLabel *>(other);
- return otherC!=0;
+ bool ret=otherC!=0;
+ if(!ret)
+ reason.insert(0,"time discretization of this is NO_TIME, other has a different time discretization.");
+ return ret;
}
bool MEDCouplingNoTimeLabel::areStrictlyCompatibleForMul(const MEDCouplingTimeDiscretization *other) const
return otherC!=0;
}
-bool MEDCouplingNoTimeLabel::isEqual(const MEDCouplingTimeDiscretization *other, double prec) const
+bool MEDCouplingNoTimeLabel::isEqualIfNotWhy(const MEDCouplingTimeDiscretization *other, double prec, std::string& reason) const
{
const MEDCouplingNoTimeLabel *otherC=dynamic_cast<const MEDCouplingNoTimeLabel *>(other);
if(!otherC)
- return false;
- return MEDCouplingTimeDiscretization::isEqual(other,prec);
+ {
+ reason="This has time discretization NO_TIME, other not.";
+ return false;
+ }
+ return MEDCouplingTimeDiscretization::isEqualIfNotWhy(other,prec,reason);
}
bool MEDCouplingNoTimeLabel::isEqualWithoutConsideringStr(const MEDCouplingTimeDiscretization *other, double prec) const
return otherC!=0;
}
-bool MEDCouplingWithTimeStep::areStrictlyCompatible(const MEDCouplingTimeDiscretization *other) const
+bool MEDCouplingWithTimeStep::areStrictlyCompatible(const MEDCouplingTimeDiscretization *other, std::string& reason) const
{
- if(!MEDCouplingTimeDiscretization::areStrictlyCompatible(other))
+ if(!MEDCouplingTimeDiscretization::areStrictlyCompatible(other,reason))
return false;
const MEDCouplingWithTimeStep *otherC=dynamic_cast<const MEDCouplingWithTimeStep *>(other);
- return otherC!=0;
+ bool ret=otherC!=0;
+ if(!ret)
+ reason.insert(0,"time discretization of this is ONE_TIME, other has a different time discretization.");
+ return ret;
}
bool MEDCouplingWithTimeStep::areStrictlyCompatibleForMul(const MEDCouplingTimeDiscretization *other) const
return otherC!=0;
}
-bool MEDCouplingWithTimeStep::isEqual(const MEDCouplingTimeDiscretization *other, double prec) const
+bool MEDCouplingWithTimeStep::isEqualIfNotWhy(const MEDCouplingTimeDiscretization *other, double prec, std::string& reason) const
{
const MEDCouplingWithTimeStep *otherC=dynamic_cast<const MEDCouplingWithTimeStep *>(other);
+ std::ostringstream oss; oss.precision(15);
if(!otherC)
- return false;
+ {
+ reason="This has time discretization ONE_TIME, other not.";
+ return false;
+ }
if(_iteration!=otherC->_iteration)
- return false;
+ {
+ oss << "iterations differ. this iteration=" << _iteration << " other iteration=" << otherC->_iteration;
+ reason=oss.str();
+ return false;
+ }
if(_order!=otherC->_order)
- return false;
+ {
+ oss << "orders differ. this order=" << _order << " other order=" << otherC->_order;
+ reason=oss.str();
+ return false;
+ }
if(std::fabs(_time-otherC->_time)>_time_tolerance)
- return false;
- return MEDCouplingTimeDiscretization::isEqual(other,prec);
+ {
+ oss << "times differ. this time=" << _time << " other time=" << otherC->_time;
+ reason=oss.str();
+ return false;
+ }
+ return MEDCouplingTimeDiscretization::isEqualIfNotWhy(other,prec,reason);
}
bool MEDCouplingWithTimeStep::isEqualWithoutConsideringStr(const MEDCouplingTimeDiscretization *other, double prec) const
return otherC!=0;
}
-bool MEDCouplingConstOnTimeInterval::areStrictlyCompatible(const MEDCouplingTimeDiscretization *other) const
+bool MEDCouplingConstOnTimeInterval::areStrictlyCompatible(const MEDCouplingTimeDiscretization *other, std::string& reason) const
{
- if(!MEDCouplingTimeDiscretization::areStrictlyCompatible(other))
+ if(!MEDCouplingTimeDiscretization::areStrictlyCompatible(other,reason))
return false;
const MEDCouplingConstOnTimeInterval *otherC=dynamic_cast<const MEDCouplingConstOnTimeInterval *>(other);
- return otherC!=0;
+ bool ret=otherC!=0;
+ if(!ret)
+ reason.insert(0,"time discretization of this is CONST_ON_TIME_INTERVAL, other has a different time discretization.");
+ return ret;
}
bool MEDCouplingConstOnTimeInterval::areStrictlyCompatibleForMul(const MEDCouplingTimeDiscretization *other) const
return otherC!=0;
}
-bool MEDCouplingConstOnTimeInterval::isEqual(const MEDCouplingTimeDiscretization *other, double prec) const
+bool MEDCouplingConstOnTimeInterval::isEqualIfNotWhy(const MEDCouplingTimeDiscretization *other, double prec, std::string& reason) const
{
const MEDCouplingConstOnTimeInterval *otherC=dynamic_cast<const MEDCouplingConstOnTimeInterval *>(other);
+ std::ostringstream oss; oss.precision(15);
if(!otherC)
- return false;
+ {
+ reason="This has time discretization CONST_ON_TIME_INTERVAL, other not.";
+ return false;
+ }
if(_start_iteration!=otherC->_start_iteration)
- return false;
+ {
+ oss << "start iterations differ. this start iteration=" << _start_iteration << " other start iteration=" << otherC->_start_iteration;
+ reason=oss.str();
+ return false;
+ }
if(_start_order!=otherC->_start_order)
- return false;
+ {
+ oss << "start orders differ. this start order=" << _start_order << " other start order=" << otherC->_start_order;
+ reason=oss.str();
+ return false;
+ }
if(std::fabs(_start_time-otherC->_start_time)>_time_tolerance)
- return false;
+ {
+ oss << "start times differ. this start time=" << _start_time << " other start time=" << otherC->_start_time;
+ reason=oss.str();
+ return false;
+ }
if(_end_iteration!=otherC->_end_iteration)
- return false;
+ {
+ oss << "end iterations differ. this end iteration=" << _end_iteration << " other end iteration=" << otherC->_end_iteration;
+ reason=oss.str();
+ return false;
+ }
if(_end_order!=otherC->_end_order)
- return false;
+ {
+ oss << "end orders differ. this end order=" << _end_order << " other end order=" << otherC->_end_order;
+ reason=oss.str();
+ return false;
+ }
if(std::fabs(_end_time-otherC->_end_time)>_time_tolerance)
- return false;
- return MEDCouplingTimeDiscretization::isEqual(other,prec);
+ {
+ oss << "end times differ. this end time=" << _end_time << " other end time=" << otherC->_end_time;
+ reason=oss.str();
+ return false;
+ }
+ return MEDCouplingTimeDiscretization::isEqualIfNotWhy(other,prec,reason);
}
bool MEDCouplingConstOnTimeInterval::isEqualWithoutConsideringStr(const MEDCouplingTimeDiscretization *other, double prec) const
throw INTERP_KERNEL::Exception("The number of tuples mismatch between the start and the end arrays !");
}
-bool MEDCouplingTwoTimeSteps::isEqual(const MEDCouplingTimeDiscretization *other, double prec) const
+bool MEDCouplingTwoTimeSteps::isEqualIfNotWhy(const MEDCouplingTimeDiscretization *other, double prec, std::string& reason) const
{
+ std::ostringstream oss;
const MEDCouplingTwoTimeSteps *otherC=dynamic_cast<const MEDCouplingTwoTimeSteps *>(other);
if(!otherC)
- return false;
+ {
+ reason="This has time discretization LINEAR_TIME, other not.";
+ return false;
+ }
if(_start_iteration!=otherC->_start_iteration)
- return false;
- if(_end_iteration!=otherC->_end_iteration)
- return false;
+ {
+ oss << "start iterations differ. this start iteration=" << _start_iteration << " other start iteration=" << otherC->_start_iteration;
+ reason=oss.str();
+ return false;
+ }
if(_start_order!=otherC->_start_order)
- return false;
- if(_end_order!=otherC->_end_order)
- return false;
+ {
+ oss << "start orders differ. this start order=" << _start_order << " other start order=" << otherC->_start_order;
+ reason=oss.str();
+ return false;
+ }
if(std::fabs(_start_time-otherC->_start_time)>_time_tolerance)
- return false;
+ {
+ oss << "start times differ. this start time=" << _start_time << " other start time=" << otherC->_start_time;
+ reason=oss.str();
+ return false;
+ }
+ if(_end_iteration!=otherC->_end_iteration)
+ {
+ oss << "end iterations differ. this end iteration=" << _end_iteration << " other end iteration=" << otherC->_end_iteration;
+ reason=oss.str();
+ return false;
+ }
+ if(_end_order!=otherC->_end_order)
+ {
+ oss << "end orders differ. this end order=" << _end_order << " other end order=" << otherC->_end_order;
+ reason=oss.str();
+ return false;
+ }
if(std::fabs(_end_time-otherC->_end_time)>_time_tolerance)
- return false;
+ {
+ oss << "end times differ. this end time=" << _end_time << " other end time=" << otherC->_end_time;
+ reason=oss.str();
+ return false;
+ }
if(_end_array!=otherC->_end_array)
- if(!_end_array->isEqual(*otherC->_end_array,prec))
+ if(!_end_array->isEqualIfNotWhy(*otherC->_end_array,prec,reason))
return false;
- return MEDCouplingTimeDiscretization::isEqual(other,prec);
+ return MEDCouplingTimeDiscretization::isEqualIfNotWhy(other,prec,reason);
}
bool MEDCouplingTwoTimeSteps::isEqualWithoutConsideringStr(const MEDCouplingTimeDiscretization *other, double prec) const
return true;
}
-bool MEDCouplingLinearTime::areStrictlyCompatible(const MEDCouplingTimeDiscretization *other) const
+bool MEDCouplingLinearTime::areStrictlyCompatible(const MEDCouplingTimeDiscretization *other, std::string& reason) const
{
- if(!MEDCouplingTimeDiscretization::areStrictlyCompatible(other))
+ if(!MEDCouplingTimeDiscretization::areStrictlyCompatible(other,reason))
return false;
const MEDCouplingLinearTime *otherC=dynamic_cast<const MEDCouplingLinearTime *>(other);
- return otherC!=0;
+ bool ret=otherC!=0;
+ if(!ret)
+ reason.insert(0,"time discretization of this is LINEAR_TIME, other has a different time discretization.");
+ return ret;
}
bool MEDCouplingLinearTime::areStrictlyCompatibleForMul(const MEDCouplingTimeDiscretization *other) const
virtual void copyTinyStringsFrom(const MEDCouplingTimeDiscretization& other);
virtual void checkCoherency() const throw(INTERP_KERNEL::Exception);
virtual bool areCompatible(const MEDCouplingTimeDiscretization *other) const;
- virtual bool areStrictlyCompatible(const MEDCouplingTimeDiscretization *other) const;
+ virtual bool areStrictlyCompatible(const MEDCouplingTimeDiscretization *other, std::string& reason) const;
virtual bool areStrictlyCompatibleForMul(const MEDCouplingTimeDiscretization *other) const;
virtual bool areStrictlyCompatibleForDiv(const MEDCouplingTimeDiscretization *other) const;
virtual bool areCompatibleForMeld(const MEDCouplingTimeDiscretization *other) const;
+ virtual bool isEqualIfNotWhy(const MEDCouplingTimeDiscretization *other, double prec, std::string& reason) const;
virtual bool isEqual(const MEDCouplingTimeDiscretization *other, double prec) const;
virtual bool isEqualWithoutConsideringStr(const MEDCouplingTimeDiscretization *other, double prec) const;
virtual MEDCouplingTimeDiscretization *buildNewTimeReprFromThis(TypeOfTimeDiscretization type, bool deepCpy) const;
void multiplyEqual(const MEDCouplingTimeDiscretization *other);
MEDCouplingTimeDiscretization *divide(const MEDCouplingTimeDiscretization *other) const;
void divideEqual(const MEDCouplingTimeDiscretization *other);
- bool isEqual(const MEDCouplingTimeDiscretization *other, double prec) const;
+ bool isEqualIfNotWhy(const MEDCouplingTimeDiscretization *other, double prec, std::string& reason) const;
bool isEqualWithoutConsideringStr(const MEDCouplingTimeDiscretization *other, double prec) const;
bool areCompatible(const MEDCouplingTimeDiscretization *other) const;
- bool areStrictlyCompatible(const MEDCouplingTimeDiscretization *other) const;
+ bool areStrictlyCompatible(const MEDCouplingTimeDiscretization *other, std::string& reason) const;
bool areStrictlyCompatibleForMul(const MEDCouplingTimeDiscretization *other) const;
bool areStrictlyCompatibleForDiv(const MEDCouplingTimeDiscretization *other) const;
bool areCompatibleForMeld(const MEDCouplingTimeDiscretization *other) const;
void multiplyEqual(const MEDCouplingTimeDiscretization *other);
MEDCouplingTimeDiscretization *divide(const MEDCouplingTimeDiscretization *other) const;
void divideEqual(const MEDCouplingTimeDiscretization *other);
- bool isEqual(const MEDCouplingTimeDiscretization *other, double prec) const;
+ bool isEqualIfNotWhy(const MEDCouplingTimeDiscretization *other, double prec, std::string& reason) const;
bool isEqualWithoutConsideringStr(const MEDCouplingTimeDiscretization *other, double prec) const;
bool areCompatible(const MEDCouplingTimeDiscretization *other) const;
- bool areStrictlyCompatible(const MEDCouplingTimeDiscretization *other) const;
+ bool areStrictlyCompatible(const MEDCouplingTimeDiscretization *other, std::string& reason) const;
bool areStrictlyCompatibleForMul(const MEDCouplingTimeDiscretization *other) const;
bool areStrictlyCompatibleForDiv(const MEDCouplingTimeDiscretization *other) const;
bool areCompatibleForMeld(const MEDCouplingTimeDiscretization *other) const;
void finishUnserialization2(const std::vector<int>& tinyInfoI, const std::vector<double>& tinyInfoD);
MEDCouplingTimeDiscretization *performCpy(bool deepCpy) const;
bool areCompatible(const MEDCouplingTimeDiscretization *other) const;
- bool areStrictlyCompatible(const MEDCouplingTimeDiscretization *other) const;
+ bool areStrictlyCompatible(const MEDCouplingTimeDiscretization *other, std::string& reason) const;
bool areStrictlyCompatibleForMul(const MEDCouplingTimeDiscretization *other) const;
bool areStrictlyCompatibleForDiv(const MEDCouplingTimeDiscretization *other) const;
bool areCompatibleForMeld(const MEDCouplingTimeDiscretization *other) const;
- bool isEqual(const MEDCouplingTimeDiscretization *other, double prec) const;
+ bool isEqualIfNotWhy(const MEDCouplingTimeDiscretization *other, double prec, std::string& reason) const;
bool isEqualWithoutConsideringStr(const MEDCouplingTimeDiscretization *other, double prec) const;
std::vector< const DataArrayDouble *> getArraysForTime(double time) const throw(INTERP_KERNEL::Exception);
void getValueForTime(double time, const std::vector<double>& vals, double *res) const;
const DataArrayDouble *getEndArray() const;
DataArrayDouble *getEndArray();
void checkCoherency() const throw(INTERP_KERNEL::Exception);
- bool isEqual(const MEDCouplingTimeDiscretization *other, double prec) const;
+ bool isEqualIfNotWhy(const MEDCouplingTimeDiscretization *other, double prec, std::string& reason) const;
bool isEqualWithoutConsideringStr(const MEDCouplingTimeDiscretization *other, double prec) const;
void checkNoTimePresence() const throw(INTERP_KERNEL::Exception);
void checkTimePresence(double time) const throw(INTERP_KERNEL::Exception);
void checkCoherency() const throw(INTERP_KERNEL::Exception);
MEDCouplingTimeDiscretization *performCpy(bool deepCpy) const;
bool areCompatible(const MEDCouplingTimeDiscretization *other) const;
- bool areStrictlyCompatible(const MEDCouplingTimeDiscretization *other) const;
+ bool areStrictlyCompatible(const MEDCouplingTimeDiscretization *other, std::string& reason) const;
bool areStrictlyCompatibleForMul(const MEDCouplingTimeDiscretization *other) const;
bool areStrictlyCompatibleForDiv(const MEDCouplingTimeDiscretization *other) const;
bool areCompatibleForMeld(const MEDCouplingTimeDiscretization *other) const;
* This method is a method that compares 'this' and 'other'.
* This method compares \b all attributes, even names and component names.
*/
-bool MEDCouplingUMesh::isEqual(const MEDCouplingMesh *other, double prec) const
+bool MEDCouplingUMesh::isEqualIfNotWhy(const MEDCouplingMesh *other, double prec, std::string& reason) const throw(INTERP_KERNEL::Exception)
{
+ if(!other)
+ throw INTERP_KERNEL::Exception("MEDCouplingUMesh::isEqualIfNotWhy : input other pointer is null !");
+ std::ostringstream oss; oss.precision(15);
const MEDCouplingUMesh *otherC=dynamic_cast<const MEDCouplingUMesh *>(other);
if(!otherC)
- return false;
- if(!MEDCouplingPointSet::isEqual(other,prec))
+ {
+ reason="mesh given in input is not castable in MEDCouplingUMesh !";
+ return false;
+ }
+ if(!MEDCouplingPointSet::isEqualIfNotWhy(other,prec,reason))
return false;
if(_mesh_dim!=otherC->_mesh_dim)
- return false;
+ {
+ oss << "umesh dimension mismatch : this mesh dimension=" << _mesh_dim << " other mesh dimension=" << otherC->_mesh_dim;
+ reason=oss.str();
+ return false;
+ }
if(_types!=otherC->_types)
- return false;
+ {
+ oss << "umesh geometric type mismatch :\nThis geometric types are :";
+ for(std::set<INTERP_KERNEL::NormalizedCellType>::const_iterator iter=_types.begin();iter!=_types.end();iter++)
+ { const INTERP_KERNEL::CellModel& cm=INTERP_KERNEL::CellModel::GetCellModel(*iter); oss << cm.getRepr() << ", "; }
+ oss << "\nOther geometric types are :";
+ for(std::set<INTERP_KERNEL::NormalizedCellType>::const_iterator iter=otherC->_types.begin();iter!=otherC->_types.end();iter++)
+ { const INTERP_KERNEL::CellModel& cm=INTERP_KERNEL::CellModel::GetCellModel(*iter); oss << cm.getRepr() << ", "; }
+ reason=oss.str();
+ return false;
+ }
if(_nodal_connec!=0 || otherC->_nodal_connec!=0)
if(_nodal_connec==0 || otherC->_nodal_connec==0)
- return false;
+ {
+ reason="Only one UMesh between the two this and other has its nodal connectivity DataArrayInt defined !";
+ return false;
+ }
if(_nodal_connec!=otherC->_nodal_connec)
- if(!_nodal_connec->isEqual(*otherC->_nodal_connec))
- return false;
+ if(!_nodal_connec->isEqualIfNotWhy(*otherC->_nodal_connec,reason))
+ {
+ reason.insert(0,"Nodal connectivity DataArrayInt differ : ");
+ return false;
+ }
if(_nodal_connec_index!=0 || otherC->_nodal_connec_index!=0)
if(_nodal_connec_index==0 || otherC->_nodal_connec_index==0)
- return false;
+ {
+ reason="Only one UMesh between the two this and other has its nodal connectivity index DataArrayInt defined !";
+ return false;
+ }
if(_nodal_connec_index!=otherC->_nodal_connec_index)
- if(!_nodal_connec_index->isEqual(*otherC->_nodal_connec_index))
- return false;
+ if(!_nodal_connec_index->isEqualIfNotWhy(*otherC->_nodal_connec_index,reason))
+ {
+ reason.insert(0,"Nodal connectivity index DataArrayInt differ : ");
+ return false;
+ }
return true;
}
MEDCOUPLING_EXPORT MEDCouplingUMesh *clone(bool recDeepCpy) const;
MEDCOUPLING_EXPORT void updateTime() const;
MEDCOUPLING_EXPORT MEDCouplingMeshType getType() const { return UNSTRUCTURED; }
- MEDCOUPLING_EXPORT bool isEqual(const MEDCouplingMesh *other, double prec) const;
+ MEDCOUPLING_EXPORT bool isEqualIfNotWhy(const MEDCouplingMesh *other, double prec, std::string& reason) const throw(INTERP_KERNEL::Exception);
MEDCOUPLING_EXPORT bool isEqualWithoutConsideringStr(const MEDCouplingMesh *other, double prec) const;
MEDCOUPLING_EXPORT void checkDeepEquivalWith(const MEDCouplingMesh *other, int cellCompPol, double prec,
DataArrayInt *&cellCor, DataArrayInt *&nodeCor) const throw(INTERP_KERNEL::Exception);
return ret;
}
- PyObject *buildPart(PyObject *li) const throw(INTERP_KERNEL::Exception)
+ PyObject *isEqualIfNotWhy(const MEDCouplingMesh *other, double prec) const throw(INTERP_KERNEL::Exception)
+ {
+ std::string ret1;
+ bool ret0=self->isEqualIfNotWhy(other,prec,ret1);
+ PyObject *ret=PyTuple_New(2);
+ PyObject *ret0Py=ret0?Py_True:Py_False;
+ Py_XINCREF(ret0Py);
+ PyTuple_SetItem(ret,0,ret0Py);
+ PyTuple_SetItem(ret,1,PyString_FromString(ret1.c_str()));
+ return ret;
+ }
+
+ PyObject *buildPart(PyObject *li) const throw(INTERP_KERNEL::Exception)
{
void *da=0;
int res1=SWIG_ConvertPtr(li,&da,SWIGTYPE_p_ParaMEDMEM__DataArrayInt, 0 | 0 );
return convertDblArrToPyList(vals,self->getNbOfElems());
}
+ PyObject *isEqualIfNotWhy(const DataArrayDouble& other, double prec) const throw(INTERP_KERNEL::Exception)
+ {
+ std::string ret1;
+ bool ret0=self->isEqualIfNotWhy(other,prec,ret1);
+ PyObject *ret=PyTuple_New(2);
+ PyObject *ret0Py=ret0?Py_True:Py_False;
+ Py_XINCREF(ret0Py);
+ PyTuple_SetItem(ret,0,ret0Py);
+ PyTuple_SetItem(ret,1,PyString_FromString(ret1.c_str()));
+ return ret;
+ }
+
PyObject *getValuesAsTuple() throw(INTERP_KERNEL::Exception)
{
const double *vals=self->getPointer();
return convertIntArrToPyList(vals,self->getNbOfElems());
}
+ PyObject *isEqualIfNotWhy(const DataArrayInt& other, double prec) const throw(INTERP_KERNEL::Exception)
+ {
+ std::string ret1;
+ bool ret0=self->isEqualIfNotWhy(other,ret1);
+ PyObject *ret=PyTuple_New(2);
+ PyObject *ret0Py=ret0?Py_True:Py_False;
+ Py_XINCREF(ret0Py);
+ PyTuple_SetItem(ret,0,ret0Py);
+ PyTuple_SetItem(ret,1,PyString_FromString(ret1.c_str()));
+ return ret;
+ }
+
PyObject *getValuesAsTuple() throw(INTERP_KERNEL::Exception)
{
const int *vals=self->getPointer();
return convertMesh(ret1, SWIG_POINTER_OWN | 0 );
}
+ PyObject *isEqualIfNotWhy(const MEDCouplingField *other, double meshPrec, double valsPrec) const throw(INTERP_KERNEL::Exception)
+ {
+ std::string ret1;
+ bool ret0=self->isEqualIfNotWhy(other,meshPrec,valsPrec,ret1);
+ PyObject *ret=PyTuple_New(2);
+ PyObject *ret0Py=ret0?Py_True:Py_False;
+ Py_XINCREF(ret0Py);
+ PyTuple_SetItem(ret,0,ret0Py);
+ PyTuple_SetItem(ret,1,PyString_FromString(ret1.c_str()));
+ return ret;
+ }
+
PyObject *buildSubMeshData(PyObject *li) const throw(INTERP_KERNEL::Exception)
{
DataArrayInt *ret1=0;