return ret;
}
-/*!
- * \a this is expected to have one component and to be sorted ascendingly (as for \a other).
- *
- * \param [in] other an array with one component and expected to be sorted ascendingly.
- * \param [out] idsInThisNotInOther list of ids in \a this but not in \a other.
- * \param [out] idsInThisAndInOther list of ids in \a this and in \a other.
- */
-void DataArrayInt::splitInTwoPartsWith(const DataArrayInt *other, DataArrayInt *&idsInThisNotInOther, DataArrayInt *&idsInThisAndInOther) const throw(INTERP_KERNEL::Exception)
-{
- static const char *MSG="DataArrayInt::splitInTwoPartsWith : only single component allowed !";
- if(!other) throw INTERP_KERNEL::Exception("DataArrayInt::splitInTwoPartsWith : NULL input array !");
- checkAllocated(); other->checkAllocated();
- if(getNumberOfComponents()!=1) throw INTERP_KERNEL::Exception(MSG);
- if(other->getNumberOfComponents()!=1) throw INTERP_KERNEL::Exception(MSG);
- const int *pt1Bg(begin()),*pt1End(end()),*pt2Bg(other->begin()),*pt2End(other->end()),*work2(pt2Bg);
- MEDCouplingAutoRefCountObjectPtr<DataArrayInt> ret0(DataArrayInt::New()),ret1(DataArrayInt::New()); ret0->alloc(0,1); ret1->alloc(0,1);
- for(const int *work1=pt1Bg;work1!=pt1End;work1++)
- {
- if(work2!=pt2End && *work1==*work2)
- { ret1->pushBackSilent(*work1); work2++; }
- else
- { ret0->pushBackSilent(*work1); }
- }
- idsInThisNotInOther=ret0.retn(); idsInThisAndInOther=ret1.retn();
-}
-
DataArrayInt *DataArrayInt::buildComplement(int nbOfElement) const throw(INTERP_KERNEL::Exception)
{
checkAllocated();
return ret;
}
+/*!
+ * \sa DataArrayInt::buildSubstractionOptimized
+ */
DataArrayInt *DataArrayInt::buildSubstraction(const DataArrayInt *other) const throw(INTERP_KERNEL::Exception)
{
if(!other)
return ret;
}
+/*!
+ * \a this is expected to have one component and to be sorted ascendingly (as for \a other).
+ * \a other is expected to be a part of \a this. If not DataArrayInt::buildSubstraction should be called instead.
+ *
+ * \param [in] other an array with one component and expected to be sorted ascendingly.
+ * \ret list of ids in \a this but not in \a other.
+ * \sa DataArrayInt::buildSubstraction
+ */
+DataArrayInt *DataArrayInt::buildSubstractionOptimized(const DataArrayInt *other) const throw(INTERP_KERNEL::Exception)
+{
+ static const char *MSG="DataArrayInt::buildSubstractionOptimized : only single component allowed !";
+ if(!other) throw INTERP_KERNEL::Exception("DataArrayInt::buildSubstractionOptimized : NULL input array !");
+ checkAllocated(); other->checkAllocated();
+ if(getNumberOfComponents()!=1) throw INTERP_KERNEL::Exception(MSG);
+ if(other->getNumberOfComponents()!=1) throw INTERP_KERNEL::Exception(MSG);
+ const int *pt1Bg(begin()),*pt1End(end()),*pt2Bg(other->begin()),*pt2End(other->end()),*work1(pt1Bg),*work2(pt2Bg);
+ MEDCouplingAutoRefCountObjectPtr<DataArrayInt> ret(DataArrayInt::New()); ret->alloc(0,1);
+ for(;work1!=pt1End;work1++)
+ {
+ if(work2!=pt2End && *work1==*work2)
+ work2++;
+ else
+ ret->pushBackSilent(*work1);
+ }
+ return ret.retn();
+}
+
DataArrayInt *DataArrayInt::buildUnion(const DataArrayInt *other) const throw(INTERP_KERNEL::Exception)
{
std::vector<const DataArrayInt *>arrs(2);
MEDCOUPLING_EXPORT static DataArrayInt *MakePartition(const std::vector<const DataArrayInt *>& groups, int newNb, std::vector< std::vector<int> >& fidsOfGroups) throw(INTERP_KERNEL::Exception);
MEDCOUPLING_EXPORT static DataArrayInt *BuildUnion(const std::vector<const DataArrayInt *>& arr) throw(INTERP_KERNEL::Exception);
MEDCOUPLING_EXPORT static DataArrayInt *BuildIntersection(const std::vector<const DataArrayInt *>& arr) throw(INTERP_KERNEL::Exception);
- MEDCOUPLING_EXPORT void splitInTwoPartsWith(const DataArrayInt *other, DataArrayInt *&idsInThisNotInOther, DataArrayInt *&idsInThisAndInOther) const 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 *buildSubstractionOptimized(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 *buildUnique() const throw(INTERP_KERNEL::Exception);
}
case Integral:
{
- MEDCouplingFieldDouble *deno=srcField->getDiscretization()->getMeasureField(srcField->getMesh(),true);
- MEDCouplingFieldDouble *denoR=trgField->getDiscretization()->getMeasureField(trgField->getMesh(),true);
+ MEDCouplingFieldDouble *deno=srcField->getDiscretization()->getMeasureField(srcField->getMesh(),getMeasureAbsStatus());
+ MEDCouplingFieldDouble *denoR=trgField->getDiscretization()->getMeasureField(trgField->getMesh(),getMeasureAbsStatus());
const double *denoPtr=deno->getArray()->getConstPointer();
const double *denoRPtr=denoR->getArray()->getConstPointer();
if(trgField->getMesh()->getMeshDimension()==-1)
}
case RevIntegral:
{
- MEDCouplingFieldDouble *deno=trgField->getDiscretization()->getMeasureField(trgField->getMesh(),true);
- MEDCouplingFieldDouble *denoR=srcField->getDiscretization()->getMeasureField(srcField->getMesh(),true);
+ MEDCouplingFieldDouble *deno=trgField->getDiscretization()->getMeasureField(trgField->getMesh(),getMeasureAbsStatus());
+ MEDCouplingFieldDouble *denoR=srcField->getDiscretization()->getMeasureField(srcField->getMesh(),getMeasureAbsStatus());
const double *denoPtr=deno->getArray()->getConstPointer();
const double *denoRPtr=denoR->getArray()->getConstPointer();
if(trgField->getMesh()->getMeshDimension()==-1)
%newobject ParaMEDMEM::DataArrayInt::buildComplement;
%newobject ParaMEDMEM::DataArrayInt::buildUnion;
%newobject ParaMEDMEM::DataArrayInt::buildSubstraction;
+%newobject ParaMEDMEM::DataArrayInt::buildSubstractionOptimized;
%newobject ParaMEDMEM::DataArrayInt::buildIntersection;
%newobject ParaMEDMEM::DataArrayInt::buildUnique;
%newobject ParaMEDMEM::DataArrayInt::deltaShiftIndex;
%extend ParaMEDMEM::DataArrayInt
{
PyObject *getDifferentValues() const throw(INTERP_KERNEL::Exception)
- {
- std::set<int> ret=self->getDifferentValues();
- return convertIntArrToPyList3(ret);
- }
+ {
+ std::set<int> ret=self->getDifferentValues();
+ return convertIntArrToPyList3(ret);
+ }
PyObject *partitionByDifferentValues() const throw(INTERP_KERNEL::Exception)
{
MEDCouplingAutoRefCountObjectPtr<DataArrayInt> ids2Tmp=famIds->getIdsEqual(*famId);
MEDCouplingAutoRefCountObjectPtr<DataArrayInt> ids2=ids->selectByTupleId(ids2Tmp->begin(),ids2Tmp->end());
MEDCouplingAutoRefCountObjectPtr<DataArrayInt> ids1=famArr->getIdsEqual(*famId);
- DataArrayInt *ret0=0,*ret1=0;
- ids1->splitInTwoPartsWith(ids2,ret0,ret1);
- MEDCouplingAutoRefCountObjectPtr<DataArrayInt> ret00(ret0),ret11(ret1);
+ MEDCouplingAutoRefCountObjectPtr<DataArrayInt> ret0(ids1->buildSubstractionOptimized(ids2));
if(ret0->empty())
{
bool isFamPresent=false;
for(std::list< MEDCouplingAutoRefCountObjectPtr<DataArrayInt> >::const_iterator itl=allFamIds.begin();itl!=allFamIds.end() && !isFamPresent;itl++)
isFamPresent=(*itl)->presenceOfValue(*famId);
if(!isFamPresent)
- { familyIds.push_back(*famId); idsPerfamiliyIds.push_back(ret00); fams.push_back(FindOrCreateAndGiveFamilyWithId(families,*famId,created)); } // adding *famId in grp
+ { familyIds.push_back(*famId); idsPerfamiliyIds.push_back(ret0); fams.push_back(FindOrCreateAndGiveFamilyWithId(families,*famId,created)); } // adding *famId in grp
else
{
- familyIds.push_back(maxVal); idsPerfamiliyIds.push_back(ret11); std::string locFamName=FindOrCreateAndGiveFamilyWithId(families,maxVal,created);
+ familyIds.push_back(maxVal); idsPerfamiliyIds.push_back(ids2); std::string locFamName=FindOrCreateAndGiveFamilyWithId(families,maxVal,created);
fams.push_back(locFamName);
if(existsFamily(*famId))
{
}
else
{
- familyIds.push_back(maxVal); idsPerfamiliyIds.push_back(ret00); // modifying all other groups on *famId to lie on maxVal and on maxVal+1
- familyIds.push_back(maxVal+1); idsPerfamiliyIds.push_back(ret11);//grp lie only on maxVal+1
+ familyIds.push_back(maxVal); idsPerfamiliyIds.push_back(ret0); // modifying all other groups on *famId to lie on maxVal and on maxVal+1
+ familyIds.push_back(maxVal+1); idsPerfamiliyIds.push_back(ids2);//grp lie only on maxVal+1
std::string n2(FindOrCreateAndGiveFamilyWithId(families,maxVal+1,created)); fams.push_back(n2);
if(existsFamily(*famId))
{
int MEDFileCMesh::getMaxFamilyIdInArrays() const throw(INTERP_KERNEL::Exception)
{
- throw INTERP_KERNEL::Exception("Tony");
+ int ret=-std::numeric_limits<int>::max(),tmp=-1;
+ if((const DataArrayInt *)_fam_nodes)
+ {
+ int val=_fam_nodes->getMaxValue(tmp);
+ ret=std::max(ret,val);
+ }
+ if((const DataArrayInt *)_fam_cells)
+ {
+ int val=_fam_cells->getMaxValue(tmp);
+ ret=std::max(ret,val);
+ }
+ return ret;
}
int MEDFileCMesh::getMinFamilyIdInArrays() const throw(INTERP_KERNEL::Exception)
{
- throw INTERP_KERNEL::Exception("Tony");
+ int ret=std::numeric_limits<int>::max(),tmp=-1;
+ if((const DataArrayInt *)_fam_nodes)
+ {
+ int val=_fam_nodes->getMinValue(tmp);
+ ret=std::min(ret,val);
+ }
+ if((const DataArrayInt *)_fam_cells)
+ {
+ int val=_fam_cells->getMinValue(tmp);
+ ret=std::min(ret,val);
+ }
+ return ret;
}
int MEDFileCMesh::getMeshDimension() const throw(INTERP_KERNEL::Exception)