X-Git-Url: http://git.salome-platform.org/gitweb/?a=blobdiff_plain;f=src%2FMEDCoupling%2FMEDCouplingMemArray.txx;h=5df4f7150b71637dd40bcf3af923036533ed8d9b;hb=b7e277ad50223814bc479c5bd64cf12abe8fc959;hp=dcb942da11fe3cfc54ae5c9b7baf088c22e39085;hpb=2c991b36a70343dfcacde2a944a136cfc2b3473e;p=tools%2Fmedcoupling.git diff --git a/src/MEDCoupling/MEDCouplingMemArray.txx b/src/MEDCoupling/MEDCouplingMemArray.txx index dcb942da1..5df4f7150 100644 --- a/src/MEDCoupling/MEDCouplingMemArray.txx +++ b/src/MEDCoupling/MEDCouplingMemArray.txx @@ -25,6 +25,7 @@ #include "NormalizedUnstructuredMesh.hxx" #include "InterpKernelException.hxx" #include "InterpolationUtils.hxx" +#include "MEDCouplingPartDefinition.hxx" #include "InterpKernelAutoPtr.hxx" #include "MCAuto.hxx" @@ -490,6 +491,30 @@ namespace MEDCoupling return ret; } + template + std::vector< MCAuto< typename Traits::ArrayTypeCh > > DataArrayTemplate::explodeComponents() const + { + checkAllocated(); + std::size_t sz(getNumberOfComponents()); + int nbTuples(getNumberOfTuples()); + std::string name(getName()); + std::vector compNames(getInfoOnComponents()); + std::vector< MCAuto< typename Traits::ArrayTypeCh > > ret(sz); + const T *thisPt(begin()); + for(std::size_t i=0;i::ArrayTypeCh > part(Traits::ArrayTypeCh::New()); + part->alloc(nbTuples,1); + part->setName(name); + part->setInfoOnComponent(0,compNames[i]); + T *otherPt(part->getPointer()); + for(int j=0;j std::size_t DataArrayTemplate::getHeapMemorySizeWithoutChildren() const { @@ -1024,6 +1049,41 @@ namespace MEDCoupling { return DataArrayTemplate::mySelectByTupleId(di.begin(),di.end()); } + + template + MCAuto::ArrayTypeCh> DataArrayTemplate::selectPartDef(const PartDefinition *pd) const + { + if(!pd) + throw INTERP_KERNEL::Exception("DataArrayTemplate::selectPartDef : null input pointer !"); + MCAuto::ArrayTypeCh> ret(Traits::ArrayTypeCh::New()); + const SlicePartDefinition *spd(dynamic_cast(pd)); + if(spd) + { + int a,b,c; + spd->getSlice(a,b,c); + if(a==0 && b==getNumberOfTuples() && c==1) + { + DataArrayTemplate *directRet(const_cast *>(this)); + directRet->incrRef(); + MCAuto > ret(directRet); + return DynamicCastSafe,typename Traits::ArrayTypeCh>(ret); + } + else + { + MCAuto ret(selectByTupleIdSafeSlice(a,b,c)); + return DynamicCastSafe::ArrayTypeCh>(ret); + } + } + const DataArrayPartDefinition *dpd(dynamic_cast(pd)); + if(dpd) + { + MCAuto arr(dpd->toDAI()); + MCAuto ret(selectByTupleIdSafe(arr->begin(),arr->end())); + return DynamicCastSafe::ArrayTypeCh>(ret); + + } + throw INTERP_KERNEL::Exception("DataArrayTemplate::selectPartDef : unrecognized part def !"); + } /*! * Returns a shorten and permuted copy of \a this array. The new DataArrayDouble is