Salome HOME
LOT7: fix compilation at med_int==int64
[modules/med.git] / src / MEDCalculator / MEDCalculatorDBSliceField.cxx
index 5311ac41442984fdbab7dce6fd1104680d9ab54d..460f2309659474d58c1aa372a150358b5ad8a6ca 100644 (file)
@@ -1,4 +1,4 @@
-// Copyright (C) 2007-2014  CEA/DEN, EDF R&D
+// Copyright (C) 2007-2019  CEA/DEN, EDF R&D
 //
 // This library is free software; you can redistribute it and/or
 // modify it under the terms of the GNU Lesser General Public
@@ -24,9 +24,9 @@
 #include "MEDLoader.hxx"
 
 #include "MEDCouplingFieldDouble.hxx"
-#include "MEDCouplingAutoRefCountObjectPtr.hxx"
+#include "MCAuto.hxx"
 
-using namespace ParaMEDMEM;
+using namespace MEDCoupling;
 
 MEDCalculatorDBSliceField::MEDCalculatorDBSliceField(int iter, int order):_iteration(iter),_order(order),_field(0),_work(0)
 {
@@ -41,7 +41,7 @@ std::size_t MEDCalculatorDBSliceField::getHeapMemorySizeWithoutChildren() const
   return 0;
 }
 
-std::vector<const BigMemoryObject *> MEDCalculatorDBSliceField::getDirectChildren() const
+std::vector<const BigMemoryObject *> MEDCalculatorDBSliceField::getDirectChildrenWithNull() const
 {
   return std::vector<const BigMemoryObject *>();
 }
@@ -73,7 +73,7 @@ void MEDCalculatorDBSliceField::write(const char *fName, const std::string& n, c
   MEDCouplingFieldDouble *myF=const_cast<MEDCouplingFieldDouble *>(_field);
   myF->setName(n.c_str());
   myF->setDescription(d.c_str());
-  MEDLoader::WriteFieldUsingAlreadyWrittenMesh(fName,_field);
+  WriteFieldUsingAlreadyWrittenMesh(fName,_field);
   myF->setName(kn.c_str());
   myF->setDescription(kd.c_str());
 }
@@ -95,7 +95,11 @@ MEDCalculatorDBSliceField::~MEDCalculatorDBSliceField()
 MEDCouplingFieldDouble *MEDCalculatorDBSliceField::getField(TypeOfField type, const std::string& fname, const std::string& mname, const std::string& fieldName) const
 {
   if(!_field)
-    _field=MEDLoader::ReadField(type,fname.c_str(),mname.c_str(),0,fieldName.c_str(),_iteration,_order);
+    {
+      MCAuto<MEDCouplingField> tmpp(ReadField(type,fname.c_str(),mname.c_str(),0,fieldName.c_str(),_iteration,_order));
+      MCAuto<MEDCouplingFieldDouble> tmp(DynamicCast<MEDCouplingField,MEDCouplingFieldDouble>(tmpp));
+      _field=tmp.retn();
+    }
   return _field;
 }
 
@@ -104,7 +108,7 @@ MEDCouplingFieldDouble *MEDCalculatorDBSliceField::getField(TypeOfField type, co
  */
 MEDCouplingFieldDouble *MEDCalculatorDBSliceField::getFieldWithoutQuestion(int sizeCThis, const MEDCalculatorDBRangeSelection& thisC) const
 {
-  std::vector<int> tIds=thisC.getIds(sizeCThis);
+  std::vector<std::size_t> tIds=thisC.getIds(sizeCThis);
   return _field->keepSelectedComponents(tIds);
 }
 
@@ -120,67 +124,67 @@ MEDCouplingFieldDouble *MEDCalculatorDBSliceField::buildCstFromThis(double val,
 void MEDCalculatorDBSliceField::assign(const MEDCalculatorDBSliceField* other, int sizeCThis, const MEDCalculatorDBRangeSelection& thisC,
                                     int sizeCOther, const MEDCalculatorDBRangeSelection& otherC)
 {
-  std::vector<int> tIds=thisC.getIds(sizeCThis);
-  std::vector<int> oIds=otherC.getIds(sizeCOther);
-  MEDCouplingAutoRefCountObjectPtr<MEDCouplingFieldDouble> f1=other->_field->keepSelectedComponents(oIds);
+  std::vector<std::size_t> tIds=thisC.getIds(sizeCThis);
+  std::vector<std::size_t> oIds=otherC.getIds(sizeCOther);
+  MCAuto<MEDCouplingFieldDouble> f1=other->_field->keepSelectedComponents(oIds);
   _field->setSelectedComponents(f1,tIds);
 }
 
-MEDCalculatorDBSliceField *MEDCalculatorDBSliceField::add(const MEDCalculatorDBSliceField* other, const DataArrayInt *cc, const DataArrayInt *nc,
+MEDCalculatorDBSliceField *MEDCalculatorDBSliceField::add(const MEDCalculatorDBSliceField* other, const DataArrayIdType *cc, const DataArrayIdType *nc,
                                                     int sizeCThis, const MEDCalculatorDBRangeSelection& thisC,
                                                     int sizeCOther, const MEDCalculatorDBRangeSelection& otherC) const
 {
   if(cc!=0 || nc!=0)
     throw INTERP_KERNEL::Exception("Slice::add : not implemented yet node/cell permutation !");
-  std::vector<int> tIds=thisC.getIds(sizeCThis);
-  std::vector<int> oIds=otherC.getIds(sizeCOther);
-  MEDCouplingAutoRefCountObjectPtr<MEDCouplingFieldDouble> f1=_field->keepSelectedComponents(tIds);
-  MEDCouplingAutoRefCountObjectPtr<MEDCouplingFieldDouble> f2=other->_field->keepSelectedComponents(oIds);
+  std::vector<std::size_t> tIds=thisC.getIds(sizeCThis);
+  std::vector<std::size_t> oIds=otherC.getIds(sizeCOther);
+  MCAuto<MEDCouplingFieldDouble> f1=_field->keepSelectedComponents(tIds);
+  MCAuto<MEDCouplingFieldDouble> f2=other->_field->keepSelectedComponents(oIds);
   f2->setMesh(f1->getMesh());
   MEDCouplingFieldDouble *f3=(*f1)+(*f2);
   return new MEDCalculatorDBSliceField(f3);
 }
 
-MEDCalculatorDBSliceField *MEDCalculatorDBSliceField::substract(const MEDCalculatorDBSliceField* other, const DataArrayInt *cc, const DataArrayInt *nc,
+MEDCalculatorDBSliceField *MEDCalculatorDBSliceField::substract(const MEDCalculatorDBSliceField* other, const DataArrayIdType *cc, const DataArrayIdType *nc,
                                                           int sizeCThis, const MEDCalculatorDBRangeSelection& thisC,
                                                           int sizeCOther, const MEDCalculatorDBRangeSelection& otherC) const
 {
   if(cc!=0 || nc!=0)
     throw INTERP_KERNEL::Exception("Slice::substract : not implemented yet node/cell permutation !");
-  std::vector<int> tIds=thisC.getIds(sizeCThis);
-  std::vector<int> oIds=otherC.getIds(sizeCOther);
-  MEDCouplingAutoRefCountObjectPtr<MEDCouplingFieldDouble> f1=_field->keepSelectedComponents(tIds);
-  MEDCouplingAutoRefCountObjectPtr<MEDCouplingFieldDouble> f2=other->_field->keepSelectedComponents(oIds);
+  std::vector<std::size_t> tIds=thisC.getIds(sizeCThis);
+  std::vector<std::size_t> oIds=otherC.getIds(sizeCOther);
+  MCAuto<MEDCouplingFieldDouble> f1=_field->keepSelectedComponents(tIds);
+  MCAuto<MEDCouplingFieldDouble> f2=other->_field->keepSelectedComponents(oIds);
   f2->setMesh(f1->getMesh());
   MEDCouplingFieldDouble *f3=(*f1)-(*f2);
   return new MEDCalculatorDBSliceField(f3);
 }
 
-MEDCalculatorDBSliceField *MEDCalculatorDBSliceField::multiply(const MEDCalculatorDBSliceField* other, const DataArrayInt *cc, const DataArrayInt *nc,
+MEDCalculatorDBSliceField *MEDCalculatorDBSliceField::multiply(const MEDCalculatorDBSliceField* other, const DataArrayIdType *cc, const DataArrayIdType *nc,
                                                          int sizeCThis, const MEDCalculatorDBRangeSelection& thisC,
                                                          int sizeCOther, const MEDCalculatorDBRangeSelection& otherC) const
 {
   if(cc!=0 || nc!=0)
     throw INTERP_KERNEL::Exception("Slice::multiply : not implemented yet node/cell permutation !");
-  std::vector<int> tIds=thisC.getIds(sizeCThis);
-  std::vector<int> oIds=otherC.getIds(sizeCOther);
-  MEDCouplingAutoRefCountObjectPtr<MEDCouplingFieldDouble> f1=_field->keepSelectedComponents(tIds);
-  MEDCouplingAutoRefCountObjectPtr<MEDCouplingFieldDouble> f2=other->_field->keepSelectedComponents(oIds);
+  std::vector<std::size_t> tIds=thisC.getIds(sizeCThis);
+  std::vector<std::size_t> oIds=otherC.getIds(sizeCOther);
+  MCAuto<MEDCouplingFieldDouble> f1=_field->keepSelectedComponents(tIds);
+  MCAuto<MEDCouplingFieldDouble> f2=other->_field->keepSelectedComponents(oIds);
   f2->setMesh(f1->getMesh());
   MEDCouplingFieldDouble *f3=(*f1)*(*f2);
   return new MEDCalculatorDBSliceField(f3);
 }
 
-MEDCalculatorDBSliceField *MEDCalculatorDBSliceField::divide(const MEDCalculatorDBSliceField* other, const DataArrayInt *cc, const DataArrayInt *nc,
+MEDCalculatorDBSliceField *MEDCalculatorDBSliceField::divide(const MEDCalculatorDBSliceField* other, const DataArrayIdType *cc, const DataArrayIdType *nc,
                                                        int sizeCThis, const MEDCalculatorDBRangeSelection& thisC,
                                                        int sizeCOther, const MEDCalculatorDBRangeSelection& otherC) const
 {
   if(cc!=0 || nc!=0)
     throw INTERP_KERNEL::Exception("Slice::divide : not implemented yet node/cell permutation !");
-  std::vector<int> tIds=thisC.getIds(sizeCThis);
-  std::vector<int> oIds=otherC.getIds(sizeCOther);
-  MEDCouplingAutoRefCountObjectPtr<MEDCouplingFieldDouble> f1=_field->keepSelectedComponents(tIds);
-  MEDCouplingAutoRefCountObjectPtr<MEDCouplingFieldDouble> f2=other->_field->keepSelectedComponents(oIds);
+  std::vector<std::size_t> tIds=thisC.getIds(sizeCThis);
+  std::vector<std::size_t> oIds=otherC.getIds(sizeCOther);
+  MCAuto<MEDCouplingFieldDouble> f1=_field->keepSelectedComponents(tIds);
+  MCAuto<MEDCouplingFieldDouble> f2=other->_field->keepSelectedComponents(oIds);
   f2->setMesh(f1->getMesh());
   MEDCouplingFieldDouble *f3=(*f1)/(*f2);
   return new MEDCalculatorDBSliceField(f3);
@@ -189,10 +193,10 @@ MEDCalculatorDBSliceField *MEDCalculatorDBSliceField::divide(const MEDCalculator
 MEDCalculatorDBSliceField *MEDCalculatorDBSliceField::dot(const MEDCalculatorDBSliceField* other, int sizeCThis, const MEDCalculatorDBRangeSelection& thisC,
                                                     int sizeCOther, const MEDCalculatorDBRangeSelection& otherC) const
 {
-  std::vector<int> tIds=thisC.getIds(sizeCThis);
-  std::vector<int> oIds=otherC.getIds(sizeCOther);
-  MEDCouplingAutoRefCountObjectPtr<MEDCouplingFieldDouble> f1=_field->keepSelectedComponents(tIds);
-  MEDCouplingAutoRefCountObjectPtr<MEDCouplingFieldDouble> f2=other->_field->keepSelectedComponents(oIds);
+  std::vector<std::size_t> tIds=thisC.getIds(sizeCThis);
+  std::vector<std::size_t> oIds=otherC.getIds(sizeCOther);
+  MCAuto<MEDCouplingFieldDouble> f1=_field->keepSelectedComponents(tIds);
+  MCAuto<MEDCouplingFieldDouble> f2=other->_field->keepSelectedComponents(oIds);
   f2->setMesh(f1->getMesh());
   MEDCouplingFieldDouble *f3=f1->dot(*f2);
   return new MEDCalculatorDBSliceField(f3);
@@ -201,10 +205,10 @@ MEDCalculatorDBSliceField *MEDCalculatorDBSliceField::dot(const MEDCalculatorDBS
 MEDCalculatorDBSliceField *MEDCalculatorDBSliceField::crossProduct(const MEDCalculatorDBSliceField* other, int sizeCThis, const MEDCalculatorDBRangeSelection& thisC,
                                                              int sizeCOther, const MEDCalculatorDBRangeSelection& otherC) const
 {
-  std::vector<int> tIds=thisC.getIds(sizeCThis);
-  std::vector<int> oIds=otherC.getIds(sizeCOther);
-  MEDCouplingAutoRefCountObjectPtr<MEDCouplingFieldDouble> f1=_field->keepSelectedComponents(tIds);
-  MEDCouplingAutoRefCountObjectPtr<MEDCouplingFieldDouble> f2=other->_field->keepSelectedComponents(oIds);
+  std::vector<std::size_t> tIds=thisC.getIds(sizeCThis);
+  std::vector<std::size_t> oIds=otherC.getIds(sizeCOther);
+  MCAuto<MEDCouplingFieldDouble> f1=_field->keepSelectedComponents(tIds);
+  MCAuto<MEDCouplingFieldDouble> f2=other->_field->keepSelectedComponents(oIds);
   f2->setMesh(f1->getMesh());
   MEDCouplingFieldDouble *f3=f1->crossProduct(*f2);
   return new MEDCalculatorDBSliceField(f3);
@@ -212,86 +216,86 @@ MEDCalculatorDBSliceField *MEDCalculatorDBSliceField::crossProduct(const MEDCalc
 
 MEDCalculatorDBSliceField *MEDCalculatorDBSliceField::doublyContractedProduct(int sizeCThis, const MEDCalculatorDBRangeSelection& thisC) const throw(INTERP_KERNEL::Exception)
 {
-  std::vector<int> tIds=thisC.getIds(sizeCThis);
-  MEDCouplingAutoRefCountObjectPtr<MEDCouplingFieldDouble> f1=_field->keepSelectedComponents(tIds);
+  std::vector<std::size_t> tIds=thisC.getIds(sizeCThis);
+  MCAuto<MEDCouplingFieldDouble> f1=_field->keepSelectedComponents(tIds);
   MEDCouplingFieldDouble *f2=f1->doublyContractedProduct();
   return new MEDCalculatorDBSliceField(f2);
 }
 
 MEDCalculatorDBSliceField *MEDCalculatorDBSliceField::determinant(int sizeCThis, const MEDCalculatorDBRangeSelection& thisC) const throw(INTERP_KERNEL::Exception)
 {
-  std::vector<int> tIds=thisC.getIds(sizeCThis);
-  MEDCouplingAutoRefCountObjectPtr<MEDCouplingFieldDouble> f1=_field->keepSelectedComponents(tIds);
+  std::vector<std::size_t> tIds=thisC.getIds(sizeCThis);
+  MCAuto<MEDCouplingFieldDouble> f1=_field->keepSelectedComponents(tIds);
   MEDCouplingFieldDouble *f2=f1->determinant();
   return new MEDCalculatorDBSliceField(f2);
 }
 
 MEDCalculatorDBSliceField *MEDCalculatorDBSliceField::eigenValues(int sizeCThis, const MEDCalculatorDBRangeSelection& thisC) const throw(INTERP_KERNEL::Exception)
 {
-  std::vector<int> tIds=thisC.getIds(sizeCThis);
-  MEDCouplingAutoRefCountObjectPtr<MEDCouplingFieldDouble> f1=_field->keepSelectedComponents(tIds);
+  std::vector<std::size_t> tIds=thisC.getIds(sizeCThis);
+  MCAuto<MEDCouplingFieldDouble> f1=_field->keepSelectedComponents(tIds);
   MEDCouplingFieldDouble *f2=f1->eigenValues();
   return new MEDCalculatorDBSliceField(f2);
 }
 
 MEDCalculatorDBSliceField *MEDCalculatorDBSliceField::eigenVectors(int sizeCThis, const MEDCalculatorDBRangeSelection& thisC) const throw(INTERP_KERNEL::Exception)
 {
-  std::vector<int> tIds=thisC.getIds(sizeCThis);
-  MEDCouplingAutoRefCountObjectPtr<MEDCouplingFieldDouble> f1=_field->keepSelectedComponents(tIds);
+  std::vector<std::size_t> tIds=thisC.getIds(sizeCThis);
+  MCAuto<MEDCouplingFieldDouble> f1=_field->keepSelectedComponents(tIds);
   MEDCouplingFieldDouble *f2=f1->eigenVectors();
   return new MEDCalculatorDBSliceField(f2);
 }
 
 MEDCalculatorDBSliceField *MEDCalculatorDBSliceField::inverse(int sizeCThis, const MEDCalculatorDBRangeSelection& thisC) const throw(INTERP_KERNEL::Exception)
 {
-  std::vector<int> tIds=thisC.getIds(sizeCThis);
-  MEDCouplingAutoRefCountObjectPtr<MEDCouplingFieldDouble> f1=_field->keepSelectedComponents(tIds);
+  std::vector<std::size_t> tIds=thisC.getIds(sizeCThis);
+  MCAuto<MEDCouplingFieldDouble> f1=_field->keepSelectedComponents(tIds);
   MEDCouplingFieldDouble *f2=f1->inverse();
   return new MEDCalculatorDBSliceField(f2);
 }
 
 MEDCalculatorDBSliceField *MEDCalculatorDBSliceField::trace(int sizeCThis, const MEDCalculatorDBRangeSelection& thisC) const throw(INTERP_KERNEL::Exception)
 {
-  std::vector<int> tIds=thisC.getIds(sizeCThis);
-  MEDCouplingAutoRefCountObjectPtr<MEDCouplingFieldDouble> f1=_field->keepSelectedComponents(tIds);
+  std::vector<std::size_t> tIds=thisC.getIds(sizeCThis);
+  MCAuto<MEDCouplingFieldDouble> f1=_field->keepSelectedComponents(tIds);
   MEDCouplingFieldDouble *f2=f1->trace();
   return new MEDCalculatorDBSliceField(f2);
 }
 
 MEDCalculatorDBSliceField *MEDCalculatorDBSliceField::deviator(int sizeCThis, const MEDCalculatorDBRangeSelection& thisC) const throw(INTERP_KERNEL::Exception)
 {
-  std::vector<int> tIds=thisC.getIds(sizeCThis);
-  MEDCouplingAutoRefCountObjectPtr<MEDCouplingFieldDouble> f1=_field->keepSelectedComponents(tIds);
+  std::vector<std::size_t> tIds=thisC.getIds(sizeCThis);
+  MCAuto<MEDCouplingFieldDouble> f1=_field->keepSelectedComponents(tIds);
   MEDCouplingFieldDouble *f2=f1->deviator();
   return new MEDCalculatorDBSliceField(f2);
 }
 
 MEDCalculatorDBSliceField *MEDCalculatorDBSliceField::magnitude(int sizeCThis, const MEDCalculatorDBRangeSelection& thisC) const throw(INTERP_KERNEL::Exception)
 {
-  std::vector<int> tIds=thisC.getIds(sizeCThis);
-  MEDCouplingAutoRefCountObjectPtr<MEDCouplingFieldDouble> f1=_field->keepSelectedComponents(tIds);
+  std::vector<std::size_t> tIds=thisC.getIds(sizeCThis);
+  MCAuto<MEDCouplingFieldDouble> f1=_field->keepSelectedComponents(tIds);
   MEDCouplingFieldDouble *f2=f1->magnitude();
   return new MEDCalculatorDBSliceField(f2);
 }
 
 void MEDCalculatorDBSliceField::applyFunc(const char *func, int sizeCThis, const MEDCalculatorDBRangeSelection& thisC)
 {
-  std::vector<int> tIds=thisC.getIds(sizeCThis);
-  MEDCouplingAutoRefCountObjectPtr<MEDCouplingFieldDouble> f1=_field->keepSelectedComponents(tIds);
+  std::vector<std::size_t> tIds=thisC.getIds(sizeCThis);
+  MCAuto<MEDCouplingFieldDouble> f1=_field->keepSelectedComponents(tIds);
   f1->applyFunc(func);
   _field->setSelectedComponents(f1,tIds);
 }
 
-bool MEDCalculatorDBSliceField::isEqual(const MEDCalculatorDBSliceField* other, const DataArrayInt *cc, const DataArrayInt *nc,
+bool MEDCalculatorDBSliceField::isEqual(const MEDCalculatorDBSliceField* other, const DataArrayIdType *cc, const DataArrayIdType *nc,
                                      int sizeCThis, const MEDCalculatorDBRangeSelection& thisC,
                                      int sizeCOther, const MEDCalculatorDBRangeSelection& otherC, double prec) const
 {
   if(cc!=0 || nc!=0)
     throw INTERP_KERNEL::Exception("Slice::isEqual : not implemented yet node/cell permutation !");
-  std::vector<int> tIds=thisC.getIds(sizeCThis);
-  std::vector<int> oIds=otherC.getIds(sizeCOther);
-  MEDCouplingAutoRefCountObjectPtr<MEDCouplingFieldDouble> f1=_field->keepSelectedComponents(tIds);
-  MEDCouplingAutoRefCountObjectPtr<MEDCouplingFieldDouble> f2=other->_field->keepSelectedComponents(oIds);
+  std::vector<std::size_t> tIds=thisC.getIds(sizeCThis);
+  std::vector<std::size_t> oIds=otherC.getIds(sizeCOther);
+  MCAuto<MEDCouplingFieldDouble> f1=_field->keepSelectedComponents(tIds);
+  MCAuto<MEDCouplingFieldDouble> f2=other->_field->keepSelectedComponents(oIds);
   f2->setMesh(f1->getMesh());
   return f1->isEqualWithoutConsideringStr(f2,0,prec);
 }