MCAuto<MEDCoupling1DGTUMesh> ret(new MEDCoupling1DGTUMesh(getName(),*_cm));
ret->setCoords(_coords);
DataArrayInt *c=0,*ci=0;
- MEDCouplingUMesh::ExtractFromIndexedArrays(begin,end,_conn,_conn_indx,c,ci);
+ DataArrayInt::ExtractFromIndexedArrays(begin,end,_conn,_conn_indx,c,ci);
MCAuto<DataArrayInt> cSafe(c),ciSafe(ci);
ret->setNodalConnectivity(c,ci);
return ret.retn();
MCAuto<MEDCoupling1DGTUMesh> ret(new MEDCoupling1DGTUMesh(getName(),*_cm));
ret->setCoords(_coords);
DataArrayInt *c=0,*ci=0;
- MEDCouplingUMesh::ExtractFromIndexedArraysSlice(start,end,step,_conn,_conn_indx,c,ci);
+ DataArrayInt::ExtractFromIndexedArraysSlice(start,end,step,_conn,_conn_indx,c,ci);
MCAuto<DataArrayInt> cSafe(c),ciSafe(ci);
ret->setNodalConnectivity(c,ci);
return ret.retn();
declareAsNew();
}
+/*!
+ * This method works on a pair input (\b arrIn, \b arrIndxIn) where \b arrIn indexes is in \b arrIndxIn
+ * (\ref numbering-indirect).
+ * This method returns the result of the extraction ( specified by a set of ids in [\b idsOfSelectBg , \b idsOfSelectEnd ) ).
+ * The selection of extraction is done standardly in new2old format.
+ * This method returns indexed arrays (\ref numbering-indirect) using 2 arrays (arrOut,arrIndexOut).
+ *
+ * \param [in] idsOfSelectBg begin of set of ids of the input extraction (included)
+ * \param [in] idsOfSelectEnd end of set of ids of the input extraction (excluded)
+ * \param [in] arrIn arr origin array from which the extraction will be done.
+ * \param [in] arrIndxIn is the input index array allowing to walk into \b arrIn
+ * \param [out] arrOut the resulting array
+ * \param [out] arrIndexOut the index array of the resulting array \b arrOut
+ * \sa DataArrayInt::ExtractFromIndexedArraysSlice
+ */
+void DataArrayInt::ExtractFromIndexedArrays(const int *idsOfSelectBg, const int *idsOfSelectEnd, const DataArrayInt *arrIn, const DataArrayInt *arrIndxIn,
+ DataArrayInt* &arrOut, DataArrayInt* &arrIndexOut)
+{
+ if(!arrIn || !arrIndxIn)
+ throw INTERP_KERNEL::Exception("DataArrayInt::ExtractFromIndexedArrays : input pointer is NULL !");
+ arrIn->checkAllocated(); arrIndxIn->checkAllocated();
+ if(arrIn->getNumberOfComponents()!=1 || arrIndxIn->getNumberOfComponents()!=1)
+ throw INTERP_KERNEL::Exception("DataArrayInt::ExtractFromIndexedArrays : input arrays must have exactly one component !");
+ std::size_t sz=std::distance(idsOfSelectBg,idsOfSelectEnd);
+ const int *arrInPtr=arrIn->begin();
+ const int *arrIndxPtr=arrIndxIn->begin();
+ int nbOfGrps=arrIndxIn->getNumberOfTuples()-1;
+ if(nbOfGrps<0)
+ throw INTERP_KERNEL::Exception("DataArrayInt::ExtractFromIndexedArrays : The format of \"arrIndxIn\" is invalid ! Its nb of tuples should be >=1 !");
+ int maxSizeOfArr=arrIn->getNumberOfTuples();
+ MCAuto<DataArrayInt> arro=DataArrayInt::New();
+ MCAuto<DataArrayInt> arrIo=DataArrayInt::New();
+ arrIo->alloc((int)(sz+1),1);
+ const int *idsIt=idsOfSelectBg;
+ int *work=arrIo->getPointer();
+ *work++=0;
+ int lgth=0;
+ for(std::size_t i=0;i<sz;i++,work++,idsIt++)
+ {
+ if(*idsIt>=0 && *idsIt<nbOfGrps)
+ lgth+=arrIndxPtr[*idsIt+1]-arrIndxPtr[*idsIt];
+ else
+ {
+ std::ostringstream oss; oss << "DataArrayInt::ExtractFromIndexedArrays : id located on pos #" << i << " value is " << *idsIt << " ! Must be in [0," << nbOfGrps << ") !";
+ throw INTERP_KERNEL::Exception(oss.str());
+ }
+ if(lgth>=work[-1])
+ *work=lgth;
+ else
+ {
+ std::ostringstream oss; oss << "DataArrayInt::ExtractFromIndexedArrays : id located on pos #" << i << " value is " << *idsIt << " and at this pos arrIndxIn[" << *idsIt;
+ oss << "+1]-arrIndxIn[" << *idsIt << "] < 0 ! The input index array is bugged !";
+ throw INTERP_KERNEL::Exception(oss.str());
+ }
+ }
+ arro->alloc(lgth,1);
+ work=arro->getPointer();
+ idsIt=idsOfSelectBg;
+ for(std::size_t i=0;i<sz;i++,idsIt++)
+ {
+ if(arrIndxPtr[*idsIt]>=0 && arrIndxPtr[*idsIt+1]<=maxSizeOfArr)
+ work=std::copy(arrInPtr+arrIndxPtr[*idsIt],arrInPtr+arrIndxPtr[*idsIt+1],work);
+ else
+ {
+ std::ostringstream oss; oss << "DataArrayInt::ExtractFromIndexedArrays : id located on pos #" << i << " value is " << *idsIt << " arrIndx[" << *idsIt << "] must be >= 0 and arrIndx[";
+ oss << *idsIt << "+1] <= " << maxSizeOfArr << " (the size of arrIn)!";
+ throw INTERP_KERNEL::Exception(oss.str());
+ }
+ }
+ arrOut=arro.retn();
+ arrIndexOut=arrIo.retn();
+}
+
+/*!
+ * This method works on a pair input (\b arrIn, \b arrIndxIn) where \b arrIn indexes is in \b arrIndxIn
+ * (\ref numbering-indirect).
+ * This method returns the result of the extraction ( specified by a set of ids with a slice given by \a idsOfSelectStart, \a idsOfSelectStop and \a idsOfSelectStep ).
+ * The selection of extraction is done standardly in new2old format.
+ * This method returns indexed arrays (\ref numbering-indirect) using 2 arrays (arrOut,arrIndexOut).
+ *
+ * \param [in] idsOfSelectStart begin of set of ids of the input extraction (included)
+ * \param [in] idsOfSelectStop end of set of ids of the input extraction (excluded)
+ * \param [in] idsOfSelectStep
+ * \param [in] arrIn arr origin array from which the extraction will be done.
+ * \param [in] arrIndxIn is the input index array allowing to walk into \b arrIn
+ * \param [out] arrOut the resulting array
+ * \param [out] arrIndexOut the index array of the resulting array \b arrOut
+ * \sa DataArrayInt::ExtractFromIndexedArrays
+ */
+void DataArrayInt::ExtractFromIndexedArraysSlice(int idsOfSelectStart, int idsOfSelectStop, int idsOfSelectStep, const DataArrayInt *arrIn, const DataArrayInt *arrIndxIn,
+ DataArrayInt* &arrOut, DataArrayInt* &arrIndexOut)
+{
+ if(!arrIn || !arrIndxIn)
+ throw INTERP_KERNEL::Exception("DataArrayInt::ExtractFromIndexedArraysSlice : input pointer is NULL !");
+ arrIn->checkAllocated(); arrIndxIn->checkAllocated();
+ if(arrIn->getNumberOfComponents()!=1 || arrIndxIn->getNumberOfComponents()!=1)
+ throw INTERP_KERNEL::Exception("DataArrayInt::ExtractFromIndexedArraysSlice : input arrays must have exactly one component !");
+ int sz=DataArrayInt::GetNumberOfItemGivenBESRelative(idsOfSelectStart,idsOfSelectStop,idsOfSelectStep,"MEDCouplingUMesh::ExtractFromIndexedArraysSlice : Input slice ");
+ const int *arrInPtr=arrIn->begin();
+ const int *arrIndxPtr=arrIndxIn->begin();
+ int nbOfGrps=arrIndxIn->getNumberOfTuples()-1;
+ if(nbOfGrps<0)
+ throw INTERP_KERNEL::Exception("DataArrayInt::ExtractFromIndexedArraysSlice : The format of \"arrIndxIn\" is invalid ! Its nb of tuples should be >=1 !");
+ int maxSizeOfArr=arrIn->getNumberOfTuples();
+ MCAuto<DataArrayInt> arro=DataArrayInt::New();
+ MCAuto<DataArrayInt> arrIo=DataArrayInt::New();
+ arrIo->alloc((int)(sz+1),1);
+ int idsIt=idsOfSelectStart;
+ int *work=arrIo->getPointer();
+ *work++=0;
+ int lgth=0;
+ for(int i=0;i<sz;i++,work++,idsIt+=idsOfSelectStep)
+ {
+ if(idsIt>=0 && idsIt<nbOfGrps)
+ lgth+=arrIndxPtr[idsIt+1]-arrIndxPtr[idsIt];
+ else
+ {
+ std::ostringstream oss; oss << "DataArrayInt::ExtractFromIndexedArraysSlice : id located on pos #" << i << " value is " << idsIt << " ! Must be in [0," << nbOfGrps << ") !";
+ throw INTERP_KERNEL::Exception(oss.str());
+ }
+ if(lgth>=work[-1])
+ *work=lgth;
+ else
+ {
+ std::ostringstream oss; oss << "DataArrayInt::ExtractFromIndexedArraysSlice : id located on pos #" << i << " value is " << idsIt << " and at this pos arrIndxIn[" << idsIt;
+ oss << "+1]-arrIndxIn[" << idsIt << "] < 0 ! The input index array is bugged !";
+ throw INTERP_KERNEL::Exception(oss.str());
+ }
+ }
+ arro->alloc(lgth,1);
+ work=arro->getPointer();
+ idsIt=idsOfSelectStart;
+ for(int i=0;i<sz;i++,idsIt+=idsOfSelectStep)
+ {
+ if(arrIndxPtr[idsIt]>=0 && arrIndxPtr[idsIt+1]<=maxSizeOfArr)
+ work=std::copy(arrInPtr+arrIndxPtr[idsIt],arrInPtr+arrIndxPtr[idsIt+1],work);
+ else
+ {
+ std::ostringstream oss; oss << "DataArrayInt::ExtractFromIndexedArraysSlice : id located on pos #" << i << " value is " << idsIt << " arrIndx[" << idsIt << "] must be >= 0 and arrIndx[";
+ oss << idsIt << "+1] <= " << maxSizeOfArr << " (the size of arrIn)!";
+ throw INTERP_KERNEL::Exception(oss.str());
+ }
+ }
+ arrOut=arro.retn();
+ arrIndexOut=arrIo.retn();
+}
+
+/*!
+ * This method works on an input pair (\b arrIn, \b arrIndxIn) where \b arrIn indexes is in \b arrIndxIn.
+ * This method builds an output pair (\b arrOut,\b arrIndexOut) that is a copy from \b arrIn for all cell ids \b not \b in [ \b idsOfSelectBg , \b idsOfSelectEnd ) and for
+ * cellIds \b in [ \b idsOfSelectBg , \b idsOfSelectEnd ) a copy coming from the corresponding values in input pair (\b srcArr, \b srcArrIndex).
+ * This method is an generalization of MEDCouplingUMesh::SetPartOfIndexedArraysSameIdx that performs the same thing but by without building explicitly a result output arrays.
+ *
+ * \param [in] idsOfSelectBg begin of set of ids of the input extraction (included)
+ * \param [in] idsOfSelectEnd end of set of ids of the input extraction (excluded)
+ * \param [in] arrIn arr origin array from which the extraction will be done.
+ * \param [in] arrIndxIn is the input index array allowing to walk into \b arrIn
+ * \param [in] srcArr input array that will be used as source of copy for ids in [ \b idsOfSelectBg, \b idsOfSelectEnd )
+ * \param [in] srcArrIndex index array of \b srcArr
+ * \param [out] arrOut the resulting array
+ * \param [out] arrIndexOut the index array of the resulting array \b arrOut
+ *
+ * \sa DataArrayInt::SetPartOfIndexedArraysSameIdx
+ */
+void DataArrayInt::SetPartOfIndexedArrays(const int *idsOfSelectBg, const int *idsOfSelectEnd, const DataArrayInt *arrIn, const DataArrayInt *arrIndxIn,
+ const DataArrayInt *srcArr, const DataArrayInt *srcArrIndex,
+ DataArrayInt* &arrOut, DataArrayInt* &arrIndexOut)
+{
+ if(arrIn==0 || arrIndxIn==0 || srcArr==0 || srcArrIndex==0)
+ throw INTERP_KERNEL::Exception("DataArrayInt::SetPartOfIndexedArrays : presence of null pointer in input parameter !");
+ MCAuto<DataArrayInt> arro=DataArrayInt::New();
+ MCAuto<DataArrayInt> arrIo=DataArrayInt::New();
+ int nbOfTuples=arrIndxIn->getNumberOfTuples()-1;
+ std::vector<bool> v(nbOfTuples,true);
+ int offset=0;
+ const int *arrIndxInPtr=arrIndxIn->begin();
+ const int *srcArrIndexPtr=srcArrIndex->begin();
+ for(const int *it=idsOfSelectBg;it!=idsOfSelectEnd;it++,srcArrIndexPtr++)
+ {
+ if(*it>=0 && *it<nbOfTuples)
+ {
+ v[*it]=false;
+ offset+=(srcArrIndexPtr[1]-srcArrIndexPtr[0])-(arrIndxInPtr[*it+1]-arrIndxInPtr[*it]);
+ }
+ else
+ {
+ std::ostringstream oss; oss << "DataArrayInt::SetPartOfIndexedArrays : On pos #" << std::distance(idsOfSelectBg,it) << " value is " << *it << " not in [0," << nbOfTuples << ") !";
+ throw INTERP_KERNEL::Exception(oss.str());
+ }
+ }
+ srcArrIndexPtr=srcArrIndex->begin();
+ arrIo->alloc(nbOfTuples+1,1);
+ arro->alloc(arrIn->getNumberOfTuples()+offset,1);
+ const int *arrInPtr=arrIn->begin();
+ const int *srcArrPtr=srcArr->begin();
+ int *arrIoPtr=arrIo->getPointer(); *arrIoPtr++=0;
+ int *arroPtr=arro->getPointer();
+ for(int ii=0;ii<nbOfTuples;ii++,arrIoPtr++)
+ {
+ if(v[ii])
+ {
+ arroPtr=std::copy(arrInPtr+arrIndxInPtr[ii],arrInPtr+arrIndxInPtr[ii+1],arroPtr);
+ *arrIoPtr=arrIoPtr[-1]+(arrIndxInPtr[ii+1]-arrIndxInPtr[ii]);
+ }
+ else
+ {
+ std::size_t pos=std::distance(idsOfSelectBg,std::find(idsOfSelectBg,idsOfSelectEnd,ii));
+ arroPtr=std::copy(srcArrPtr+srcArrIndexPtr[pos],srcArrPtr+srcArrIndexPtr[pos+1],arroPtr);
+ *arrIoPtr=arrIoPtr[-1]+(srcArrIndexPtr[pos+1]-srcArrIndexPtr[pos]);
+ }
+ }
+ arrOut=arro.retn();
+ arrIndexOut=arrIo.retn();
+}
+
+
+/*!
+ * This method works on an input pair (\b arrIn, \b arrIndxIn) where \b arrIn indexes is in \b arrIndxIn.
+ * This method builds an output pair (\b arrOut,\b arrIndexOut) that is a copy from \b arrIn for all cell ids \b not \b in [ \b idsOfSelectBg , \b idsOfSelectEnd ) and for
+ * cellIds \b in [\b idsOfSelectBg, \b idsOfSelectEnd) a copy coming from the corresponding values in input pair (\b srcArr, \b srcArrIndex).
+ * This method is an generalization of DataArrayInt::SetPartOfIndexedArraysSameIdx that performs the same thing but by without building explicitly a result output arrays.
+ *
+ * \param [in] start begin of set of ids of the input extraction (included)
+ * \param [in] end end of set of ids of the input extraction (excluded)
+ * \param [in] step step of the set of ids in range mode.
+ * \param [in] arrIn arr origin array from which the extraction will be done.
+ * \param [in] arrIndxIn is the input index array allowing to walk into \b arrIn
+ * \param [in] srcArr input array that will be used as source of copy for ids in [\b idsOfSelectBg, \b idsOfSelectEnd)
+ * \param [in] srcArrIndex index array of \b srcArr
+ * \param [out] arrOut the resulting array
+ * \param [out] arrIndexOut the index array of the resulting array \b arrOut
+ *
+ * \sa DataArrayInt::SetPartOfIndexedArraysSameIdx DataArrayInt::SetPartOfIndexedArrays
+ */
+void DataArrayInt::SetPartOfIndexedArraysSlice(int start, int end, int step, const DataArrayInt *arrIn, const DataArrayInt *arrIndxIn,
+ const DataArrayInt *srcArr, const DataArrayInt *srcArrIndex,
+ DataArrayInt* &arrOut, DataArrayInt* &arrIndexOut)
+{
+ if(arrIn==0 || arrIndxIn==0 || srcArr==0 || srcArrIndex==0)
+ throw INTERP_KERNEL::Exception("DataArrayInt::SetPartOfIndexedArraysSlice : presence of null pointer in input parameter !");
+ MCAuto<DataArrayInt> arro=DataArrayInt::New();
+ MCAuto<DataArrayInt> arrIo=DataArrayInt::New();
+ int nbOfTuples=arrIndxIn->getNumberOfTuples()-1;
+ int offset=0;
+ const int *arrIndxInPtr=arrIndxIn->begin();
+ const int *srcArrIndexPtr=srcArrIndex->begin();
+ int nbOfElemsToSet=DataArray::GetNumberOfItemGivenBESRelative(start,end,step,"DataArrayInt::SetPartOfIndexedArraysSlice : ");
+ int it=start;
+ for(int i=0;i<nbOfElemsToSet;i++,srcArrIndexPtr++,it+=step)
+ {
+ if(it>=0 && it<nbOfTuples)
+ offset+=(srcArrIndexPtr[1]-srcArrIndexPtr[0])-(arrIndxInPtr[it+1]-arrIndxInPtr[it]);
+ else
+ {
+ std::ostringstream oss; oss << "DataArrayInt::SetPartOfIndexedArraysSlice : On pos #" << i << " value is " << it << " not in [0," << nbOfTuples << ") !";
+ throw INTERP_KERNEL::Exception(oss.str());
+ }
+ }
+ srcArrIndexPtr=srcArrIndex->begin();
+ arrIo->alloc(nbOfTuples+1,1);
+ arro->alloc(arrIn->getNumberOfTuples()+offset,1);
+ const int *arrInPtr=arrIn->begin();
+ const int *srcArrPtr=srcArr->begin();
+ int *arrIoPtr=arrIo->getPointer(); *arrIoPtr++=0;
+ int *arroPtr=arro->getPointer();
+ for(int ii=0;ii<nbOfTuples;ii++,arrIoPtr++)
+ {
+ int pos=DataArray::GetPosOfItemGivenBESRelativeNoThrow(ii,start,end,step);
+ if(pos<0)
+ {
+ arroPtr=std::copy(arrInPtr+arrIndxInPtr[ii],arrInPtr+arrIndxInPtr[ii+1],arroPtr);
+ *arrIoPtr=arrIoPtr[-1]+(arrIndxInPtr[ii+1]-arrIndxInPtr[ii]);
+ }
+ else
+ {
+ arroPtr=std::copy(srcArrPtr+srcArrIndexPtr[pos],srcArrPtr+srcArrIndexPtr[pos+1],arroPtr);
+ *arrIoPtr=arrIoPtr[-1]+(srcArrIndexPtr[pos+1]-srcArrIndexPtr[pos]);
+ }
+ }
+ arrOut=arro.retn();
+ arrIndexOut=arrIo.retn();
+}
+
+
+/*!
+ * This method works on an input pair (\b arrIn, \b arrIndxIn) where \b arrIn indexes is in \b arrIndxIn.
+ * This method is an specialization of MEDCouplingUMesh::SetPartOfIndexedArrays in the case of assignment do not modify the index in \b arrIndxIn.
+ *
+ * \param [in] idsOfSelectBg begin of set of ids of the input extraction (included)
+ * \param [in] idsOfSelectEnd end of set of ids of the input extraction (excluded)
+ * \param [in,out] arrInOut arr origin array from which the extraction will be done.
+ * \param [in] arrIndxIn is the input index array allowing to walk into \b arrIn
+ * \param [in] srcArr input array that will be used as source of copy for ids in [ \b idsOfSelectBg , \b idsOfSelectEnd )
+ * \param [in] srcArrIndex index array of \b srcArr
+ *
+ * \sa DataArrayInt::SetPartOfIndexedArrays
+ */
+void DataArrayInt::SetPartOfIndexedArraysSameIdx(const int *idsOfSelectBg, const int *idsOfSelectEnd, DataArrayInt *arrInOut, const DataArrayInt *arrIndxIn,
+ const DataArrayInt *srcArr, const DataArrayInt *srcArrIndex)
+{
+ if(arrInOut==0 || arrIndxIn==0 || srcArr==0 || srcArrIndex==0)
+ throw INTERP_KERNEL::Exception("DataArrayInt::SetPartOfIndexedArraysSameIdx : presence of null pointer in input parameter !");
+ int nbOfTuples=arrIndxIn->getNumberOfTuples()-1;
+ const int *arrIndxInPtr=arrIndxIn->begin();
+ const int *srcArrIndexPtr=srcArrIndex->begin();
+ int *arrInOutPtr=arrInOut->getPointer();
+ const int *srcArrPtr=srcArr->begin();
+ for(const int *it=idsOfSelectBg;it!=idsOfSelectEnd;it++,srcArrIndexPtr++)
+ {
+ if(*it>=0 && *it<nbOfTuples)
+ {
+ if(srcArrIndexPtr[1]-srcArrIndexPtr[0]==arrIndxInPtr[*it+1]-arrIndxInPtr[*it])
+ std::copy(srcArrPtr+srcArrIndexPtr[0],srcArrPtr+srcArrIndexPtr[1],arrInOutPtr+arrIndxInPtr[*it]);
+ else
+ {
+ std::ostringstream oss; oss << "DataArrayInt::SetPartOfIndexedArraysSameIdx : On pos #" << std::distance(idsOfSelectBg,it) << " id (idsOfSelectBg[" << std::distance(idsOfSelectBg,it)<< "]) is " << *it << " arrIndxIn[id+1]-arrIndxIn[id]!=srcArrIndex[pos+1]-srcArrIndex[pos] !";
+ throw INTERP_KERNEL::Exception(oss.str());
+ }
+ }
+ else
+ {
+ std::ostringstream oss; oss << "DataArrayInt::SetPartOfIndexedArraysSameIdx : On pos #" << std::distance(idsOfSelectBg,it) << " value is " << *it << " not in [0," << nbOfTuples << ") !";
+ throw INTERP_KERNEL::Exception(oss.str());
+ }
+ }
+}
+
+/*!
+ * This method works on an input pair (\b arr, \b arrIndx) where \b arr indexes is in \b arrIndx.
+ * This method will not impact the size of inout parameter \b arrIndx but the size of \b arr will be modified in case of suppression.
+ *
+ * \param [in] idsToRemoveBg begin of set of ids to remove in \b arr (included)
+ * \param [in] idsToRemoveEnd end of set of ids to remove in \b arr (excluded)
+ * \param [in,out] arr array in which the remove operation will be done.
+ * \param [in,out] arrIndx array in the remove operation will modify
+ * \param [in] offsetForRemoval (by default 0) offset so that for each i in [0,arrIndx->getNumberOfTuples()-1) removal process will be performed in the following range [arr+arrIndx[i]+offsetForRemoval,arr+arr[i+1])
+ * \return true if \b arr and \b arrIndx have been modified, false if not.
+ */
+bool DataArrayInt::RemoveIdsFromIndexedArrays(const int *idsToRemoveBg, const int *idsToRemoveEnd, DataArrayInt *arr, DataArrayInt *arrIndx, int offsetForRemoval)
+{
+ if(!arrIndx || !arr)
+ throw INTERP_KERNEL::Exception("DataArrayInt::RemoveIdsFromIndexedArrays : some input arrays are empty !");
+ if(offsetForRemoval<0)
+ throw INTERP_KERNEL::Exception("DataArrayInt::RemoveIdsFromIndexedArrays : offsetForRemoval should be >=0 !");
+ std::set<int> s(idsToRemoveBg,idsToRemoveEnd);
+ int nbOfGrps=arrIndx->getNumberOfTuples()-1;
+ int *arrIPtr=arrIndx->getPointer();
+ *arrIPtr++=0;
+ int previousArrI=0;
+ const int *arrPtr=arr->begin();
+ std::vector<int> arrOut;//no utility to switch to DataArrayInt because copy always needed
+ for(int i=0;i<nbOfGrps;i++,arrIPtr++)
+ {
+ if(*arrIPtr-previousArrI>offsetForRemoval)
+ {
+ for(const int *work=arrPtr+previousArrI+offsetForRemoval;work!=arrPtr+*arrIPtr;work++)
+ {
+ if(s.find(*work)==s.end())
+ arrOut.push_back(*work);
+ }
+ }
+ previousArrI=*arrIPtr;
+ *arrIPtr=(int)arrOut.size();
+ }
+ if(arr->getNumberOfTuples()==arrOut.size())
+ return false;
+ arr->alloc((int)arrOut.size(),1);
+ std::copy(arrOut.begin(),arrOut.end(),arr->getPointer());
+ return true;
+}
+
+/*!
+ * This method works on an input pair (\b arrIn, \b arrIndxIn) where \b arrIn indexes is in \b arrIndxIn.
+ * This method is an specialization of MEDCouplingUMesh::SetPartOfIndexedArrays in the case of assignment do not modify the index in \b arrIndxIn.
+ *
+ * \param [in] start begin of set of ids of the input extraction (included)
+ * \param [in] end end of set of ids of the input extraction (excluded)
+ * \param [in] step step of the set of ids in range mode.
+ * \param [in,out] arrInOut arr origin array from which the extraction will be done.
+ * \param [in] arrIndxIn is the input index array allowing to walk into \b arrIn
+ * \param [in] srcArr input array that will be used as source of copy for ids in [\b idsOfSelectBg, \b idsOfSelectEnd)
+ * \param [in] srcArrIndex index array of \b srcArr
+ *
+ * \sa DataArrayInt::SetPartOfIndexedArraysSlice DataArrayInt::SetPartOfIndexedArraysSameIdx
+ */
+void DataArrayInt::SetPartOfIndexedArraysSameIdxSlice(int start, int end, int step, DataArrayInt *arrInOut, const DataArrayInt *arrIndxIn,
+ const DataArrayInt *srcArr, const DataArrayInt *srcArrIndex)
+{
+ if(arrInOut==0 || arrIndxIn==0 || srcArr==0 || srcArrIndex==0)
+ throw INTERP_KERNEL::Exception("DataArrayInt::SetPartOfIndexedArraysSameIdxSlice : presence of null pointer in input parameter !");
+ int nbOfTuples=arrIndxIn->getNumberOfTuples()-1;
+ const int *arrIndxInPtr=arrIndxIn->begin();
+ const int *srcArrIndexPtr=srcArrIndex->begin();
+ int *arrInOutPtr=arrInOut->getPointer();
+ const int *srcArrPtr=srcArr->begin();
+ int nbOfElemsToSet=DataArray::GetNumberOfItemGivenBESRelative(start,end,step,"DataArrayInt::SetPartOfIndexedArraysSameIdxSlice : ");
+ int it=start;
+ for(int i=0;i<nbOfElemsToSet;i++,srcArrIndexPtr++,it+=step)
+ {
+ if(it>=0 && it<nbOfTuples)
+ {
+ if(srcArrIndexPtr[1]-srcArrIndexPtr[0]==arrIndxInPtr[it+1]-arrIndxInPtr[it])
+ std::copy(srcArrPtr+srcArrIndexPtr[0],srcArrPtr+srcArrIndexPtr[1],arrInOutPtr+arrIndxInPtr[it]);
+ else
+ {
+ std::ostringstream oss; oss << "DataArrayInt::SetPartOfIndexedArraysSameIdxSlice : On pos #" << i << " id (idsOfSelectBg[" << i << "]) is " << it << " arrIndxIn[id+1]-arrIndxIn[id]!=srcArrIndex[pos+1]-srcArrIndex[pos] !";
+ throw INTERP_KERNEL::Exception(oss.str());
+ }
+ }
+ else
+ {
+ std::ostringstream oss; oss << "DataArrayInt::SetPartOfIndexedArraysSameIdxSlice : On pos #" << i << " value is " << it << " not in [0," << nbOfTuples << ") !";
+ throw INTERP_KERNEL::Exception(oss.str());
+ }
+ }
+}
+
+
/*!
* Returns a C array which is a renumbering map in "Old to New" mode for the input array.
* This map, if applied to \a start array, would make it sorted. For example, if
MEDCOUPLING_EXPORT MemArray<int>& accessToMemArray() { return _mem; }
MEDCOUPLING_EXPORT const MemArray<int>& accessToMemArray() const { return _mem; }
public:
+ MEDCOUPLING_EXPORT static void ExtractFromIndexedArrays(const int *idsOfSelectBg, const int *idsOfSelectEnd, const DataArrayInt *arrIn, const DataArrayInt *arrIndxIn,
+ DataArrayInt* &arrOut, DataArrayInt* &arrIndexOut);
+ MEDCOUPLING_EXPORT static void ExtractFromIndexedArraysSlice(int idsOfSelectStart, int idsOfSelectStop, int idsOfSelectStep, const DataArrayInt *arrIn, const DataArrayInt *arrIndxIn,
+ DataArrayInt* &arrOut, DataArrayInt* &arrIndexOut);
+ MEDCOUPLING_EXPORT static void SetPartOfIndexedArrays(const int *idsOfSelectBg, const int *idsOfSelectEnd, const DataArrayInt *arrIn, const DataArrayInt *arrIndxIn,
+ const DataArrayInt *srcArr, const DataArrayInt *srcArrIndex,
+ DataArrayInt* &arrOut, DataArrayInt* &arrIndexOut);
+ MEDCOUPLING_EXPORT static void SetPartOfIndexedArraysSlice(int start, int end, int step, const DataArrayInt *arrIn, const DataArrayInt *arrIndxIn,
+ const DataArrayInt *srcArr, const DataArrayInt *srcArrIndex,
+ DataArrayInt* &arrOut, DataArrayInt* &arrIndexOut);
+ MEDCOUPLING_EXPORT static void SetPartOfIndexedArraysSameIdx(const int *idsOfSelectBg, const int *idsOfSelectEnd, DataArrayInt *arrInOut, const DataArrayInt *arrIndxIn,
+ const DataArrayInt *srcArr, const DataArrayInt *srcArrIndex);
+ MEDCOUPLING_EXPORT static void SetPartOfIndexedArraysSameIdxSlice(int start, int end, int step, DataArrayInt *arrInOut, const DataArrayInt *arrIndxIn,
+ const DataArrayInt *srcArr, const DataArrayInt *srcArrIndex);
+ MEDCOUPLING_EXPORT static bool RemoveIdsFromIndexedArrays(const int *idsToRemoveBg, const int *idsToRemoveEnd, DataArrayInt *arr, DataArrayInt *arrIndx, int offsetForRemoval=0);
MEDCOUPLING_EXPORT static int *CheckAndPreparePermutation(const int *start, const int *end);
MEDCOUPLING_EXPORT static DataArrayInt32 *Range(int begin, int end, int step);
public:
}
if(easyAssign)
{
- MEDCouplingUMesh::SetPartOfIndexedArraysSameIdx(cellIdsBg,cellIdsEnd,_nodal_connec,_nodal_connec_index,otherOnSameCoordsThanThis._nodal_connec,otherOnSameCoordsThanThis._nodal_connec_index);
+ DataArrayInt::SetPartOfIndexedArraysSameIdx(cellIdsBg,cellIdsEnd,_nodal_connec,_nodal_connec_index,otherOnSameCoordsThanThis._nodal_connec,otherOnSameCoordsThanThis._nodal_connec_index);
computeTypes();
}
else
{
DataArrayInt *arrOut=0,*arrIOut=0;
- MEDCouplingUMesh::SetPartOfIndexedArrays(cellIdsBg,cellIdsEnd,_nodal_connec,_nodal_connec_index,otherOnSameCoordsThanThis._nodal_connec,otherOnSameCoordsThanThis._nodal_connec_index,
+ DataArrayInt::SetPartOfIndexedArrays(cellIdsBg,cellIdsEnd,_nodal_connec,_nodal_connec_index,otherOnSameCoordsThanThis._nodal_connec,otherOnSameCoordsThanThis._nodal_connec_index,
arrOut,arrIOut);
MCAuto<DataArrayInt> arrOutAuto(arrOut),arrIOutAuto(arrIOut);
setConnectivity(arrOut,arrIOut,true);
}
if(easyAssign)
{
- MEDCouplingUMesh::SetPartOfIndexedArraysSameIdxSlice(start,end,step,_nodal_connec,_nodal_connec_index,otherOnSameCoordsThanThis._nodal_connec,otherOnSameCoordsThanThis._nodal_connec_index);
+ DataArrayInt::SetPartOfIndexedArraysSameIdxSlice(start,end,step,_nodal_connec,_nodal_connec_index,otherOnSameCoordsThanThis._nodal_connec,otherOnSameCoordsThanThis._nodal_connec_index);
computeTypes();
}
else
{
DataArrayInt *arrOut=0,*arrIOut=0;
- MEDCouplingUMesh::SetPartOfIndexedArraysSlice(start,end,step,_nodal_connec,_nodal_connec_index,otherOnSameCoordsThanThis._nodal_connec,otherOnSameCoordsThanThis._nodal_connec_index,
+ DataArrayInt::SetPartOfIndexedArraysSlice(start,end,step,_nodal_connec,_nodal_connec_index,otherOnSameCoordsThanThis._nodal_connec,otherOnSameCoordsThanThis._nodal_connec_index,
arrOut,arrIOut);
MCAuto<DataArrayInt> arrOutAuto(arrOut),arrIOutAuto(arrIOut);
setConnectivity(arrOut,arrIOut,true);
DAInt ids(idsTmp);
// In the neighbor information remove the connection between high dimension cells and its low level constituents which are part
// of the frontier given in parameter (i.e. the cells of low dimension from the group delimiting the crack):
- MEDCouplingUMesh::RemoveIdsFromIndexedArrays(ids->begin(),ids->end(),desc00,descI00);
+ DataArrayInt::RemoveIdsFromIndexedArrays(ids->begin(),ids->end(),desc00,descI00);
DataArrayInt *tmp0=0,*tmp1=0;
// Compute the neighbor of each cell in m0Part2, taking into account the broken link above. Two
// cells on either side of the crack (defined by the mesh of low dimension) are not neighbor anymore.
throw INTERP_KERNEL::Exception("MEDCouplingUMesh::BuildConvexEnvelopOf2DCellJarvis : invalid 2D cell connectivity !");
}
-/*!
- * This method works on an input pair (\b arr, \b arrIndx) where \b arr indexes is in \b arrIndx.
- * This method will not impact the size of inout parameter \b arrIndx but the size of \b arr will be modified in case of suppression.
- *
- * \param [in] idsToRemoveBg begin of set of ids to remove in \b arr (included)
- * \param [in] idsToRemoveEnd end of set of ids to remove in \b arr (excluded)
- * \param [in,out] arr array in which the remove operation will be done.
- * \param [in,out] arrIndx array in the remove operation will modify
- * \param [in] offsetForRemoval (by default 0) offset so that for each i in [0,arrIndx->getNumberOfTuples()-1) removal process will be performed in the following range [arr+arrIndx[i]+offsetForRemoval,arr+arr[i+1])
- * \return true if \b arr and \b arrIndx have been modified, false if not.
- */
-bool MEDCouplingUMesh::RemoveIdsFromIndexedArrays(const int *idsToRemoveBg, const int *idsToRemoveEnd, DataArrayInt *arr, DataArrayInt *arrIndx, int offsetForRemoval)
-{
- if(!arrIndx || !arr)
- throw INTERP_KERNEL::Exception("MEDCouplingUMesh::RemoveIdsFromIndexedArrays : some input arrays are empty !");
- if(offsetForRemoval<0)
- throw INTERP_KERNEL::Exception("MEDCouplingUMesh::RemoveIdsFromIndexedArrays : offsetForRemoval should be >=0 !");
- std::set<int> s(idsToRemoveBg,idsToRemoveEnd);
- int nbOfGrps=arrIndx->getNumberOfTuples()-1;
- int *arrIPtr=arrIndx->getPointer();
- *arrIPtr++=0;
- int previousArrI=0;
- const int *arrPtr=arr->begin();
- std::vector<int> arrOut;//no utility to switch to DataArrayInt because copy always needed
- for(int i=0;i<nbOfGrps;i++,arrIPtr++)
- {
- if(*arrIPtr-previousArrI>offsetForRemoval)
- {
- for(const int *work=arrPtr+previousArrI+offsetForRemoval;work!=arrPtr+*arrIPtr;work++)
- {
- if(s.find(*work)==s.end())
- arrOut.push_back(*work);
- }
- }
- previousArrI=*arrIPtr;
- *arrIPtr=(int)arrOut.size();
- }
- if(arr->getNumberOfTuples()==arrOut.size())
- return false;
- arr->alloc((int)arrOut.size(),1);
- std::copy(arrOut.begin(),arrOut.end(),arr->getPointer());
- return true;
-}
-
-/*!
- * This method works on a pair input (\b arrIn, \b arrIndxIn) where \b arrIn indexes is in \b arrIndxIn
- * (\ref numbering-indirect).
- * This method returns the result of the extraction ( specified by a set of ids in [\b idsOfSelectBg , \b idsOfSelectEnd ) ).
- * The selection of extraction is done standardly in new2old format.
- * This method returns indexed arrays (\ref numbering-indirect) using 2 arrays (arrOut,arrIndexOut).
- *
- * \param [in] idsOfSelectBg begin of set of ids of the input extraction (included)
- * \param [in] idsOfSelectEnd end of set of ids of the input extraction (excluded)
- * \param [in] arrIn arr origin array from which the extraction will be done.
- * \param [in] arrIndxIn is the input index array allowing to walk into \b arrIn
- * \param [out] arrOut the resulting array
- * \param [out] arrIndexOut the index array of the resulting array \b arrOut
- * \sa MEDCouplingUMesh::ExtractFromIndexedArraysSlice
- */
-void MEDCouplingUMesh::ExtractFromIndexedArrays(const int *idsOfSelectBg, const int *idsOfSelectEnd, const DataArrayInt *arrIn, const DataArrayInt *arrIndxIn,
- DataArrayInt* &arrOut, DataArrayInt* &arrIndexOut)
-{
- if(!arrIn || !arrIndxIn)
- throw INTERP_KERNEL::Exception("MEDCouplingUMesh::ExtractFromIndexedArrays : input pointer is NULL !");
- arrIn->checkAllocated(); arrIndxIn->checkAllocated();
- if(arrIn->getNumberOfComponents()!=1 || arrIndxIn->getNumberOfComponents()!=1)
- throw INTERP_KERNEL::Exception("MEDCouplingUMesh::ExtractFromIndexedArrays : input arrays must have exactly one component !");
- std::size_t sz=std::distance(idsOfSelectBg,idsOfSelectEnd);
- const int *arrInPtr=arrIn->begin();
- const int *arrIndxPtr=arrIndxIn->begin();
- int nbOfGrps=arrIndxIn->getNumberOfTuples()-1;
- if(nbOfGrps<0)
- throw INTERP_KERNEL::Exception("MEDCouplingUMesh::ExtractFromIndexedArrays : The format of \"arrIndxIn\" is invalid ! Its nb of tuples should be >=1 !");
- int maxSizeOfArr=arrIn->getNumberOfTuples();
- MCAuto<DataArrayInt> arro=DataArrayInt::New();
- MCAuto<DataArrayInt> arrIo=DataArrayInt::New();
- arrIo->alloc((int)(sz+1),1);
- const int *idsIt=idsOfSelectBg;
- int *work=arrIo->getPointer();
- *work++=0;
- int lgth=0;
- for(std::size_t i=0;i<sz;i++,work++,idsIt++)
- {
- if(*idsIt>=0 && *idsIt<nbOfGrps)
- lgth+=arrIndxPtr[*idsIt+1]-arrIndxPtr[*idsIt];
- else
- {
- std::ostringstream oss; oss << "MEDCouplingUMesh::ExtractFromIndexedArrays : id located on pos #" << i << " value is " << *idsIt << " ! Must be in [0," << nbOfGrps << ") !";
- throw INTERP_KERNEL::Exception(oss.str());
- }
- if(lgth>=work[-1])
- *work=lgth;
- else
- {
- std::ostringstream oss; oss << "MEDCouplingUMesh::ExtractFromIndexedArrays : id located on pos #" << i << " value is " << *idsIt << " and at this pos arrIndxIn[" << *idsIt;
- oss << "+1]-arrIndxIn[" << *idsIt << "] < 0 ! The input index array is bugged !";
- throw INTERP_KERNEL::Exception(oss.str());
- }
- }
- arro->alloc(lgth,1);
- work=arro->getPointer();
- idsIt=idsOfSelectBg;
- for(std::size_t i=0;i<sz;i++,idsIt++)
- {
- if(arrIndxPtr[*idsIt]>=0 && arrIndxPtr[*idsIt+1]<=maxSizeOfArr)
- work=std::copy(arrInPtr+arrIndxPtr[*idsIt],arrInPtr+arrIndxPtr[*idsIt+1],work);
- else
- {
- std::ostringstream oss; oss << "MEDCouplingUMesh::ExtractFromIndexedArrays : id located on pos #" << i << " value is " << *idsIt << " arrIndx[" << *idsIt << "] must be >= 0 and arrIndx[";
- oss << *idsIt << "+1] <= " << maxSizeOfArr << " (the size of arrIn)!";
- throw INTERP_KERNEL::Exception(oss.str());
- }
- }
- arrOut=arro.retn();
- arrIndexOut=arrIo.retn();
-}
-
-/*!
- * This method works on a pair input (\b arrIn, \b arrIndxIn) where \b arrIn indexes is in \b arrIndxIn
- * (\ref numbering-indirect).
- * This method returns the result of the extraction ( specified by a set of ids with a slice given by \a idsOfSelectStart, \a idsOfSelectStop and \a idsOfSelectStep ).
- * The selection of extraction is done standardly in new2old format.
- * This method returns indexed arrays (\ref numbering-indirect) using 2 arrays (arrOut,arrIndexOut).
- *
- * \param [in] idsOfSelectStart begin of set of ids of the input extraction (included)
- * \param [in] idsOfSelectStop end of set of ids of the input extraction (excluded)
- * \param [in] idsOfSelectStep
- * \param [in] arrIn arr origin array from which the extraction will be done.
- * \param [in] arrIndxIn is the input index array allowing to walk into \b arrIn
- * \param [out] arrOut the resulting array
- * \param [out] arrIndexOut the index array of the resulting array \b arrOut
- * \sa MEDCouplingUMesh::ExtractFromIndexedArrays
- */
-void MEDCouplingUMesh::ExtractFromIndexedArraysSlice(int idsOfSelectStart, int idsOfSelectStop, int idsOfSelectStep, const DataArrayInt *arrIn, const DataArrayInt *arrIndxIn,
- DataArrayInt* &arrOut, DataArrayInt* &arrIndexOut)
-{
- if(!arrIn || !arrIndxIn)
- throw INTERP_KERNEL::Exception("MEDCouplingUMesh::ExtractFromIndexedArraysSlice : input pointer is NULL !");
- arrIn->checkAllocated(); arrIndxIn->checkAllocated();
- if(arrIn->getNumberOfComponents()!=1 || arrIndxIn->getNumberOfComponents()!=1)
- throw INTERP_KERNEL::Exception("MEDCouplingUMesh::ExtractFromIndexedArraysSlice : input arrays must have exactly one component !");
- int sz=DataArrayInt::GetNumberOfItemGivenBESRelative(idsOfSelectStart,idsOfSelectStop,idsOfSelectStep,"MEDCouplingUMesh::ExtractFromIndexedArraysSlice : Input slice ");
- const int *arrInPtr=arrIn->begin();
- const int *arrIndxPtr=arrIndxIn->begin();
- int nbOfGrps=arrIndxIn->getNumberOfTuples()-1;
- if(nbOfGrps<0)
- throw INTERP_KERNEL::Exception("MEDCouplingUMesh::ExtractFromIndexedArraysSlice : The format of \"arrIndxIn\" is invalid ! Its nb of tuples should be >=1 !");
- int maxSizeOfArr=arrIn->getNumberOfTuples();
- MCAuto<DataArrayInt> arro=DataArrayInt::New();
- MCAuto<DataArrayInt> arrIo=DataArrayInt::New();
- arrIo->alloc((int)(sz+1),1);
- int idsIt=idsOfSelectStart;
- int *work=arrIo->getPointer();
- *work++=0;
- int lgth=0;
- for(int i=0;i<sz;i++,work++,idsIt+=idsOfSelectStep)
- {
- if(idsIt>=0 && idsIt<nbOfGrps)
- lgth+=arrIndxPtr[idsIt+1]-arrIndxPtr[idsIt];
- else
- {
- std::ostringstream oss; oss << "MEDCouplingUMesh::ExtractFromIndexedArraysSlice : id located on pos #" << i << " value is " << idsIt << " ! Must be in [0," << nbOfGrps << ") !";
- throw INTERP_KERNEL::Exception(oss.str());
- }
- if(lgth>=work[-1])
- *work=lgth;
- else
- {
- std::ostringstream oss; oss << "MEDCouplingUMesh::ExtractFromIndexedArraysSlice : id located on pos #" << i << " value is " << idsIt << " and at this pos arrIndxIn[" << idsIt;
- oss << "+1]-arrIndxIn[" << idsIt << "] < 0 ! The input index array is bugged !";
- throw INTERP_KERNEL::Exception(oss.str());
- }
- }
- arro->alloc(lgth,1);
- work=arro->getPointer();
- idsIt=idsOfSelectStart;
- for(int i=0;i<sz;i++,idsIt+=idsOfSelectStep)
- {
- if(arrIndxPtr[idsIt]>=0 && arrIndxPtr[idsIt+1]<=maxSizeOfArr)
- work=std::copy(arrInPtr+arrIndxPtr[idsIt],arrInPtr+arrIndxPtr[idsIt+1],work);
- else
- {
- std::ostringstream oss; oss << "MEDCouplingUMesh::ExtractFromIndexedArraysSlice : id located on pos #" << i << " value is " << idsIt << " arrIndx[" << idsIt << "] must be >= 0 and arrIndx[";
- oss << idsIt << "+1] <= " << maxSizeOfArr << " (the size of arrIn)!";
- throw INTERP_KERNEL::Exception(oss.str());
- }
- }
- arrOut=arro.retn();
- arrIndexOut=arrIo.retn();
-}
-
-/*!
- * This method works on an input pair (\b arrIn, \b arrIndxIn) where \b arrIn indexes is in \b arrIndxIn.
- * This method builds an output pair (\b arrOut,\b arrIndexOut) that is a copy from \b arrIn for all cell ids \b not \b in [ \b idsOfSelectBg , \b idsOfSelectEnd ) and for
- * cellIds \b in [ \b idsOfSelectBg , \b idsOfSelectEnd ) a copy coming from the corresponding values in input pair (\b srcArr, \b srcArrIndex).
- * This method is an generalization of MEDCouplingUMesh::SetPartOfIndexedArraysSameIdx that performs the same thing but by without building explicitly a result output arrays.
- *
- * \param [in] idsOfSelectBg begin of set of ids of the input extraction (included)
- * \param [in] idsOfSelectEnd end of set of ids of the input extraction (excluded)
- * \param [in] arrIn arr origin array from which the extraction will be done.
- * \param [in] arrIndxIn is the input index array allowing to walk into \b arrIn
- * \param [in] srcArr input array that will be used as source of copy for ids in [ \b idsOfSelectBg, \b idsOfSelectEnd )
- * \param [in] srcArrIndex index array of \b srcArr
- * \param [out] arrOut the resulting array
- * \param [out] arrIndexOut the index array of the resulting array \b arrOut
- *
- * \sa MEDCouplingUMesh::SetPartOfIndexedArraysSameIdx
- */
-void MEDCouplingUMesh::SetPartOfIndexedArrays(const int *idsOfSelectBg, const int *idsOfSelectEnd, const DataArrayInt *arrIn, const DataArrayInt *arrIndxIn,
- const DataArrayInt *srcArr, const DataArrayInt *srcArrIndex,
- DataArrayInt* &arrOut, DataArrayInt* &arrIndexOut)
-{
- if(arrIn==0 || arrIndxIn==0 || srcArr==0 || srcArrIndex==0)
- throw INTERP_KERNEL::Exception("MEDCouplingUMesh::SetPartOfIndexedArrays : presence of null pointer in input parameter !");
- MCAuto<DataArrayInt> arro=DataArrayInt::New();
- MCAuto<DataArrayInt> arrIo=DataArrayInt::New();
- int nbOfTuples=arrIndxIn->getNumberOfTuples()-1;
- std::vector<bool> v(nbOfTuples,true);
- int offset=0;
- const int *arrIndxInPtr=arrIndxIn->begin();
- const int *srcArrIndexPtr=srcArrIndex->begin();
- for(const int *it=idsOfSelectBg;it!=idsOfSelectEnd;it++,srcArrIndexPtr++)
- {
- if(*it>=0 && *it<nbOfTuples)
- {
- v[*it]=false;
- offset+=(srcArrIndexPtr[1]-srcArrIndexPtr[0])-(arrIndxInPtr[*it+1]-arrIndxInPtr[*it]);
- }
- else
- {
- std::ostringstream oss; oss << "MEDCouplingUMesh::SetPartOfIndexedArrays : On pos #" << std::distance(idsOfSelectBg,it) << " value is " << *it << " not in [0," << nbOfTuples << ") !";
- throw INTERP_KERNEL::Exception(oss.str());
- }
- }
- srcArrIndexPtr=srcArrIndex->begin();
- arrIo->alloc(nbOfTuples+1,1);
- arro->alloc(arrIn->getNumberOfTuples()+offset,1);
- const int *arrInPtr=arrIn->begin();
- const int *srcArrPtr=srcArr->begin();
- int *arrIoPtr=arrIo->getPointer(); *arrIoPtr++=0;
- int *arroPtr=arro->getPointer();
- for(int ii=0;ii<nbOfTuples;ii++,arrIoPtr++)
- {
- if(v[ii])
- {
- arroPtr=std::copy(arrInPtr+arrIndxInPtr[ii],arrInPtr+arrIndxInPtr[ii+1],arroPtr);
- *arrIoPtr=arrIoPtr[-1]+(arrIndxInPtr[ii+1]-arrIndxInPtr[ii]);
- }
- else
- {
- std::size_t pos=std::distance(idsOfSelectBg,std::find(idsOfSelectBg,idsOfSelectEnd,ii));
- arroPtr=std::copy(srcArrPtr+srcArrIndexPtr[pos],srcArrPtr+srcArrIndexPtr[pos+1],arroPtr);
- *arrIoPtr=arrIoPtr[-1]+(srcArrIndexPtr[pos+1]-srcArrIndexPtr[pos]);
- }
- }
- arrOut=arro.retn();
- arrIndexOut=arrIo.retn();
-}
-
-/*!
- * This method works on an input pair (\b arrIn, \b arrIndxIn) where \b arrIn indexes is in \b arrIndxIn.
- * This method is an specialization of MEDCouplingUMesh::SetPartOfIndexedArrays in the case of assignment do not modify the index in \b arrIndxIn.
- *
- * \param [in] idsOfSelectBg begin of set of ids of the input extraction (included)
- * \param [in] idsOfSelectEnd end of set of ids of the input extraction (excluded)
- * \param [in,out] arrInOut arr origin array from which the extraction will be done.
- * \param [in] arrIndxIn is the input index array allowing to walk into \b arrIn
- * \param [in] srcArr input array that will be used as source of copy for ids in [ \b idsOfSelectBg , \b idsOfSelectEnd )
- * \param [in] srcArrIndex index array of \b srcArr
- *
- * \sa MEDCouplingUMesh::SetPartOfIndexedArrays
- */
-void MEDCouplingUMesh::SetPartOfIndexedArraysSameIdx(const int *idsOfSelectBg, const int *idsOfSelectEnd, DataArrayInt *arrInOut, const DataArrayInt *arrIndxIn,
- const DataArrayInt *srcArr, const DataArrayInt *srcArrIndex)
-{
- if(arrInOut==0 || arrIndxIn==0 || srcArr==0 || srcArrIndex==0)
- throw INTERP_KERNEL::Exception("MEDCouplingUMesh::SetPartOfIndexedArraysSameIdx : presence of null pointer in input parameter !");
- int nbOfTuples=arrIndxIn->getNumberOfTuples()-1;
- const int *arrIndxInPtr=arrIndxIn->begin();
- const int *srcArrIndexPtr=srcArrIndex->begin();
- int *arrInOutPtr=arrInOut->getPointer();
- const int *srcArrPtr=srcArr->begin();
- for(const int *it=idsOfSelectBg;it!=idsOfSelectEnd;it++,srcArrIndexPtr++)
- {
- if(*it>=0 && *it<nbOfTuples)
- {
- if(srcArrIndexPtr[1]-srcArrIndexPtr[0]==arrIndxInPtr[*it+1]-arrIndxInPtr[*it])
- std::copy(srcArrPtr+srcArrIndexPtr[0],srcArrPtr+srcArrIndexPtr[1],arrInOutPtr+arrIndxInPtr[*it]);
- else
- {
- std::ostringstream oss; oss << "MEDCouplingUMesh::SetPartOfIndexedArraysSameIdx : On pos #" << std::distance(idsOfSelectBg,it) << " id (idsOfSelectBg[" << std::distance(idsOfSelectBg,it)<< "]) is " << *it << " arrIndxIn[id+1]-arrIndxIn[id]!=srcArrIndex[pos+1]-srcArrIndex[pos] !";
- throw INTERP_KERNEL::Exception(oss.str());
- }
- }
- else
- {
- std::ostringstream oss; oss << "MEDCouplingUMesh::SetPartOfIndexedArraysSameIdx : On pos #" << std::distance(idsOfSelectBg,it) << " value is " << *it << " not in [0," << nbOfTuples << ") !";
- throw INTERP_KERNEL::Exception(oss.str());
- }
- }
-}
-
/*!
* This method works on a pair input (\b arrIn, \b arrIndxIn) where \b arr indexes is in \b arrIndxIn.
* This method expects that these two input arrays come from the output of MEDCouplingUMesh::computeNeighborsOfCells method.
}
-/*!
- * This method works on an input pair (\b arrIn, \b arrIndxIn) where \b arrIn indexes is in \b arrIndxIn.
- * This method builds an output pair (\b arrOut,\b arrIndexOut) that is a copy from \b arrIn for all cell ids \b not \b in [ \b idsOfSelectBg , \b idsOfSelectEnd ) and for
- * cellIds \b in [\b idsOfSelectBg, \b idsOfSelectEnd) a copy coming from the corresponding values in input pair (\b srcArr, \b srcArrIndex).
- * This method is an generalization of MEDCouplingUMesh::SetPartOfIndexedArraysSameIdx that performs the same thing but by without building explicitly a result output arrays.
- *
- * \param [in] start begin of set of ids of the input extraction (included)
- * \param [in] end end of set of ids of the input extraction (excluded)
- * \param [in] step step of the set of ids in range mode.
- * \param [in] arrIn arr origin array from which the extraction will be done.
- * \param [in] arrIndxIn is the input index array allowing to walk into \b arrIn
- * \param [in] srcArr input array that will be used as source of copy for ids in [\b idsOfSelectBg, \b idsOfSelectEnd)
- * \param [in] srcArrIndex index array of \b srcArr
- * \param [out] arrOut the resulting array
- * \param [out] arrIndexOut the index array of the resulting array \b arrOut
- *
- * \sa MEDCouplingUMesh::SetPartOfIndexedArraysSameIdx MEDCouplingUMesh::SetPartOfIndexedArrays
- */
-void MEDCouplingUMesh::SetPartOfIndexedArraysSlice(int start, int end, int step, const DataArrayInt *arrIn, const DataArrayInt *arrIndxIn,
- const DataArrayInt *srcArr, const DataArrayInt *srcArrIndex,
- DataArrayInt* &arrOut, DataArrayInt* &arrIndexOut)
-{
- if(arrIn==0 || arrIndxIn==0 || srcArr==0 || srcArrIndex==0)
- throw INTERP_KERNEL::Exception("MEDCouplingUMesh::SetPartOfIndexedArraysSlice : presence of null pointer in input parameter !");
- MCAuto<DataArrayInt> arro=DataArrayInt::New();
- MCAuto<DataArrayInt> arrIo=DataArrayInt::New();
- int nbOfTuples=arrIndxIn->getNumberOfTuples()-1;
- int offset=0;
- const int *arrIndxInPtr=arrIndxIn->begin();
- const int *srcArrIndexPtr=srcArrIndex->begin();
- int nbOfElemsToSet=DataArray::GetNumberOfItemGivenBESRelative(start,end,step,"MEDCouplingUMesh::SetPartOfIndexedArraysSlice : ");
- int it=start;
- for(int i=0;i<nbOfElemsToSet;i++,srcArrIndexPtr++,it+=step)
- {
- if(it>=0 && it<nbOfTuples)
- offset+=(srcArrIndexPtr[1]-srcArrIndexPtr[0])-(arrIndxInPtr[it+1]-arrIndxInPtr[it]);
- else
- {
- std::ostringstream oss; oss << "MEDCouplingUMesh::SetPartOfIndexedArraysSlice : On pos #" << i << " value is " << it << " not in [0," << nbOfTuples << ") !";
- throw INTERP_KERNEL::Exception(oss.str());
- }
- }
- srcArrIndexPtr=srcArrIndex->begin();
- arrIo->alloc(nbOfTuples+1,1);
- arro->alloc(arrIn->getNumberOfTuples()+offset,1);
- const int *arrInPtr=arrIn->begin();
- const int *srcArrPtr=srcArr->begin();
- int *arrIoPtr=arrIo->getPointer(); *arrIoPtr++=0;
- int *arroPtr=arro->getPointer();
- for(int ii=0;ii<nbOfTuples;ii++,arrIoPtr++)
- {
- int pos=DataArray::GetPosOfItemGivenBESRelativeNoThrow(ii,start,end,step);
- if(pos<0)
- {
- arroPtr=std::copy(arrInPtr+arrIndxInPtr[ii],arrInPtr+arrIndxInPtr[ii+1],arroPtr);
- *arrIoPtr=arrIoPtr[-1]+(arrIndxInPtr[ii+1]-arrIndxInPtr[ii]);
- }
- else
- {
- arroPtr=std::copy(srcArrPtr+srcArrIndexPtr[pos],srcArrPtr+srcArrIndexPtr[pos+1],arroPtr);
- *arrIoPtr=arrIoPtr[-1]+(srcArrIndexPtr[pos+1]-srcArrIndexPtr[pos]);
- }
- }
- arrOut=arro.retn();
- arrIndexOut=arrIo.retn();
-}
-
-/*!
- * This method works on an input pair (\b arrIn, \b arrIndxIn) where \b arrIn indexes is in \b arrIndxIn.
- * This method is an specialization of MEDCouplingUMesh::SetPartOfIndexedArrays in the case of assignment do not modify the index in \b arrIndxIn.
- *
- * \param [in] start begin of set of ids of the input extraction (included)
- * \param [in] end end of set of ids of the input extraction (excluded)
- * \param [in] step step of the set of ids in range mode.
- * \param [in,out] arrInOut arr origin array from which the extraction will be done.
- * \param [in] arrIndxIn is the input index array allowing to walk into \b arrIn
- * \param [in] srcArr input array that will be used as source of copy for ids in [\b idsOfSelectBg, \b idsOfSelectEnd)
- * \param [in] srcArrIndex index array of \b srcArr
- *
- * \sa MEDCouplingUMesh::SetPartOfIndexedArraysSlice MEDCouplingUMesh::SetPartOfIndexedArraysSameIdx
- */
-void MEDCouplingUMesh::SetPartOfIndexedArraysSameIdxSlice(int start, int end, int step, DataArrayInt *arrInOut, const DataArrayInt *arrIndxIn,
- const DataArrayInt *srcArr, const DataArrayInt *srcArrIndex)
-{
- if(arrInOut==0 || arrIndxIn==0 || srcArr==0 || srcArrIndex==0)
- throw INTERP_KERNEL::Exception("MEDCouplingUMesh::SetPartOfIndexedArraysSameIdxSlice : presence of null pointer in input parameter !");
- int nbOfTuples=arrIndxIn->getNumberOfTuples()-1;
- const int *arrIndxInPtr=arrIndxIn->begin();
- const int *srcArrIndexPtr=srcArrIndex->begin();
- int *arrInOutPtr=arrInOut->getPointer();
- const int *srcArrPtr=srcArr->begin();
- int nbOfElemsToSet=DataArray::GetNumberOfItemGivenBESRelative(start,end,step,"MEDCouplingUMesh::SetPartOfIndexedArraysSameIdxSlice : ");
- int it=start;
- for(int i=0;i<nbOfElemsToSet;i++,srcArrIndexPtr++,it+=step)
- {
- if(it>=0 && it<nbOfTuples)
- {
- if(srcArrIndexPtr[1]-srcArrIndexPtr[0]==arrIndxInPtr[it+1]-arrIndxInPtr[it])
- std::copy(srcArrPtr+srcArrIndexPtr[0],srcArrPtr+srcArrIndexPtr[1],arrInOutPtr+arrIndxInPtr[it]);
- else
- {
- std::ostringstream oss; oss << "MEDCouplingUMesh::SetPartOfIndexedArraysSameIdxSlice : On pos #" << i << " id (idsOfSelectBg[" << i << "]) is " << it << " arrIndxIn[id+1]-arrIndxIn[id]!=srcArrIndex[pos+1]-srcArrIndex[pos] !";
- throw INTERP_KERNEL::Exception(oss.str());
- }
- }
- else
- {
- std::ostringstream oss; oss << "MEDCouplingUMesh::SetPartOfIndexedArraysSameIdxSlice : On pos #" << i << " value is " << it << " not in [0," << nbOfTuples << ") !";
- throw INTERP_KERNEL::Exception(oss.str());
- }
- }
-}
/*!
* \b this is expected to be a mesh fully defined whose spaceDim==meshDim.
MEDCOUPLING_EXPORT static void Intersect2DMeshWith1DLine(const MEDCouplingUMesh *mesh2D, const MEDCouplingUMesh *mesh1D,
double eps, MEDCouplingUMesh *&splitMesh2D, MEDCouplingUMesh *&splitMesh1D, DataArrayInt *&cellIdInMesh2D, DataArrayInt *&cellIdInMesh1D);
MEDCOUPLING_EXPORT static bool BuildConvexEnvelopOf2DCellJarvis(const double *coords, const int *nodalConnBg, const int *nodalConnEnd, DataArrayInt *nodalConnecOut);
- MEDCOUPLING_EXPORT static bool RemoveIdsFromIndexedArrays(const int *idsToRemoveBg, const int *idsToRemoveEnd, DataArrayInt *arr, DataArrayInt *arrIndx, int offsetForRemoval=0);
- MEDCOUPLING_EXPORT static void ExtractFromIndexedArrays(const int *idsOfSelectBg, const int *idsOfSelectEnd, const DataArrayInt *arrIn, const DataArrayInt *arrIndxIn,
- DataArrayInt* &arrOut, DataArrayInt* &arrIndexOut);
- MEDCOUPLING_EXPORT static void ExtractFromIndexedArraysSlice(int idsOfSelectStart, int idsOfSelectStop, int idsOfSelectStep, const DataArrayInt *arrIn, const DataArrayInt *arrIndxIn,
- DataArrayInt* &arrOut, DataArrayInt* &arrIndexOut);
- MEDCOUPLING_EXPORT static void SetPartOfIndexedArrays(const int *idsOfSelectBg, const int *idsOfSelectEnd, const DataArrayInt *arrIn, const DataArrayInt *arrIndxIn,
- const DataArrayInt *srcArr, const DataArrayInt *srcArrIndex,
- DataArrayInt* &arrOut, DataArrayInt* &arrIndexOut);
- MEDCOUPLING_EXPORT static void SetPartOfIndexedArraysSameIdx(const int *idsOfSelectBg, const int *idsOfSelectEnd, DataArrayInt *arrInOut, const DataArrayInt *arrIndxIn,
- const DataArrayInt *srcArr, const DataArrayInt *srcArrIndex);
- MEDCOUPLING_EXPORT static void SetPartOfIndexedArraysSlice(int start, int end, int step, const DataArrayInt *arrIn, const DataArrayInt *arrIndxIn,
- const DataArrayInt *srcArr, const DataArrayInt *srcArrIndex,
- DataArrayInt* &arrOut, DataArrayInt* &arrIndexOut);
- MEDCOUPLING_EXPORT static void SetPartOfIndexedArraysSameIdxSlice(int start, int end, int step, DataArrayInt *arrInOut, const DataArrayInt *arrIndxIn,
- const DataArrayInt *srcArr, const DataArrayInt *srcArrIndex);
MEDCOUPLING_EXPORT static std::vector<DataArrayInt *> PartitionBySpreadZone(const DataArrayInt *arrIn, const DataArrayInt *arrIndxIn);
MEDCOUPLING_EXPORT static DataArrayInt *ComputeSpreadZoneGradually(const DataArrayInt *arrIn, const DataArrayInt *arrIndxIn);
MEDCOUPLING_EXPORT static DataArrayInt *ComputeSpreadZoneGraduallyFromSeed(const int *seedBg, const int *seedEnd, const DataArrayInt *arrIn, const DataArrayInt *arrIndxIn, int nbOfDepthPeeling, int& nbOfDepthPeelingPerformed);
if(!idsInDesc2DToBeRefined->empty())
{
DataArrayInt *out0(0),*outi0(0);
- MEDCouplingUMesh::ExtractFromIndexedArrays(idsInDesc2DToBeRefined->begin(),idsInDesc2DToBeRefined->end(),dd3,dd4,out0,outi0);
+ DataArrayInt::ExtractFromIndexedArrays(idsInDesc2DToBeRefined->begin(),idsInDesc2DToBeRefined->end(),dd3,dd4,out0,outi0);
MCAuto<DataArrayInt> outi0s(outi0);
out0s=out0;
out0s=out0s->buildUnique();
//
MCAuto<DataArrayInt> mSafe,nSafe,oSafe,pSafe,qSafe,rSafe;
DataArrayInt *m(0),*n(0),*o(0),*p(0),*q(0),*r(0);
- MEDCouplingUMesh::ExtractFromIndexedArrays(ret->begin(),ret->end(),desc1,descIndx1,m,n); mSafe=m; nSafe=n;
+ DataArrayInt::ExtractFromIndexedArrays(ret->begin(),ret->end(),desc1,descIndx1,m,n); mSafe=m; nSafe=n;
DataArrayInt::PutIntoToSkylineFrmt(intersectEdge,o,p); oSafe=o; pSafe=p;
if(middleNeedsToBeUsed)
{ DataArrayInt::PutIntoToSkylineFrmt(middle,q,r); qSafe=q; rSafe=r; }
MEDCouplingUMesh::MergeNodesOnUMeshesSharingSameCoords(meshes,eps);
}
- static bool RemoveIdsFromIndexedArrays(PyObject *li, DataArrayInt *arr, DataArrayInt *arrIndx, int offsetForRemoval=0)
- {
- int sw;
- int singleVal;
- std::vector<int> multiVal;
- std::pair<int, std::pair<int,int> > slic;
- MEDCoupling::DataArrayInt *daIntTyypp=0;
- if(!arrIndx)
- throw INTERP_KERNEL::Exception("MEDCouplingUMesh::RemoveIdsFromIndexedArrays : null pointer as arrIndex !");
- convertIntStarOrSliceLikePyObjToCpp(li,arrIndx->getNumberOfTuples()-1,sw,singleVal,multiVal,slic,daIntTyypp);
- switch(sw)
- {
- case 1:
- return MEDCouplingUMesh::RemoveIdsFromIndexedArrays(&singleVal,&singleVal+1,arr,arrIndx,offsetForRemoval);
- case 2:
- return MEDCouplingUMesh::RemoveIdsFromIndexedArrays(&multiVal[0],&multiVal[0]+multiVal.size(),arr,arrIndx,offsetForRemoval);
- case 4:
- return MEDCouplingUMesh::RemoveIdsFromIndexedArrays(daIntTyypp->begin(),daIntTyypp->end(),arr,arrIndx,offsetForRemoval);
- default:
- throw INTERP_KERNEL::Exception("MEDCouplingUMesh::RemoveIdsFromIndexedArrays : unrecognized type entered, expected list of int, tuple of int or DataArrayInt !");
- }
- }
-
- static PyObject *ExtractFromIndexedArrays(PyObject *li, const DataArrayInt *arrIn, const DataArrayInt *arrIndxIn)
- {
- DataArrayInt *arrOut=0,*arrIndexOut=0;
- int sw;
- int singleVal;
- std::vector<int> multiVal;
- std::pair<int, std::pair<int,int> > slic;
- MEDCoupling::DataArrayInt *daIntTyypp=0;
- if(!arrIndxIn)
- throw INTERP_KERNEL::Exception("MEDCouplingUMesh::ExtractFromIndexedArrays : null pointer as arrIndxIn !");
- convertIntStarOrSliceLikePyObjToCpp(li,arrIndxIn->getNumberOfTuples()-1,sw,singleVal,multiVal,slic,daIntTyypp);
- switch(sw)
- {
- case 1:
- {
- MEDCouplingUMesh::ExtractFromIndexedArrays(&singleVal,&singleVal+1,arrIn,arrIndxIn,arrOut,arrIndexOut);
- break;
- }
- case 2:
- {
- MEDCouplingUMesh::ExtractFromIndexedArrays(&multiVal[0],&multiVal[0]+multiVal.size(),arrIn,arrIndxIn,arrOut,arrIndexOut);
- break;
- }
- case 4:
- {
- MEDCouplingUMesh::ExtractFromIndexedArrays(daIntTyypp->begin(),daIntTyypp->end(),arrIn,arrIndxIn,arrOut,arrIndexOut);
- break;
- }
- default:
- throw INTERP_KERNEL::Exception("MEDCouplingUMesh::ExtractFromIndexedArrays : unrecognized type entered, expected list of int, tuple of int or DataArrayInt !");
- }
- PyObject *ret=PyTuple_New(2);
- PyTuple_SetItem(ret,0,SWIG_NewPointerObj(SWIG_as_voidptr(arrOut),SWIGTYPE_p_MEDCoupling__DataArrayInt, SWIG_POINTER_OWN | 0 ));
- PyTuple_SetItem(ret,1,SWIG_NewPointerObj(SWIG_as_voidptr(arrIndexOut),SWIGTYPE_p_MEDCoupling__DataArrayInt, SWIG_POINTER_OWN | 0 ));
- return ret;
- }
-
- static PyObject *ExtractFromIndexedArraysSlice(int strt, int stp, int step, const DataArrayInt *arrIn, const DataArrayInt *arrIndxIn)
- {
- DataArrayInt *arrOut=0,*arrIndexOut=0;
- MEDCouplingUMesh::ExtractFromIndexedArraysSlice(strt,stp,step,arrIn,arrIndxIn,arrOut,arrIndexOut);
- PyObject *ret=PyTuple_New(2);
- PyTuple_SetItem(ret,0,SWIG_NewPointerObj(SWIG_as_voidptr(arrOut),SWIGTYPE_p_MEDCoupling__DataArrayInt, SWIG_POINTER_OWN | 0 ));
- PyTuple_SetItem(ret,1,SWIG_NewPointerObj(SWIG_as_voidptr(arrIndexOut),SWIGTYPE_p_MEDCoupling__DataArrayInt, SWIG_POINTER_OWN | 0 ));
- return ret;
- }
-
- static PyObject *ExtractFromIndexedArraysSlice(PyObject *slic, const DataArrayInt *arrIn, const DataArrayInt *arrIndxIn)
- {
- if(!PySlice_Check(slic))
- throw INTERP_KERNEL::Exception("ExtractFromIndexedArraysSlice (wrap) : the first param is not a pyslice !");
- Py_ssize_t strt=2,stp=2,step=2;
- if(!arrIndxIn)
- throw INTERP_KERNEL::Exception("ExtractFromIndexedArraysSlice (wrap) : last array is null !");
- arrIndxIn->checkAllocated();
- if(arrIndxIn->getNumberOfComponents()!=1)
- throw INTERP_KERNEL::Exception("ExtractFromIndexedArraysSlice (wrap) : number of components of last argument must be equal to one !");
- GetIndicesOfSlice(slic,arrIndxIn->getNumberOfTuples(),&strt,&stp,&step,"ExtractFromIndexedArraysSlice (wrap) : Invalid slice regarding nb of elements !");
- DataArrayInt *arrOut=0,*arrIndexOut=0;
- MEDCouplingUMesh::ExtractFromIndexedArraysSlice(strt,stp,step,arrIn,arrIndxIn,arrOut,arrIndexOut);
- PyObject *ret=PyTuple_New(2);
- PyTuple_SetItem(ret,0,SWIG_NewPointerObj(SWIG_as_voidptr(arrOut),SWIGTYPE_p_MEDCoupling__DataArrayInt, SWIG_POINTER_OWN | 0 ));
- PyTuple_SetItem(ret,1,SWIG_NewPointerObj(SWIG_as_voidptr(arrIndexOut),SWIGTYPE_p_MEDCoupling__DataArrayInt, SWIG_POINTER_OWN | 0 ));
- return ret;
- }
-
- static PyObject *SetPartOfIndexedArrays(PyObject *li,
- const DataArrayInt *arrIn, const DataArrayInt *arrIndxIn,
- const DataArrayInt *srcArr, const DataArrayInt *srcArrIndex)
- {
- DataArrayInt *arrOut=0,*arrIndexOut=0;
- int sw;
- int singleVal;
- std::vector<int> multiVal;
- std::pair<int, std::pair<int,int> > slic;
- MEDCoupling::DataArrayInt *daIntTyypp=0;
- if(!arrIndxIn)
- throw INTERP_KERNEL::Exception("MEDCouplingUMesh::SetPartOfIndexedArrays : null pointer as arrIndex !");
- convertIntStarOrSliceLikePyObjToCpp(li,arrIndxIn->getNumberOfTuples()-1,sw,singleVal,multiVal,slic,daIntTyypp);
- switch(sw)
- {
- case 1:
- {
- MEDCouplingUMesh::SetPartOfIndexedArrays(&singleVal,&singleVal+1,arrIn,arrIndxIn,srcArr,srcArrIndex,arrOut,arrIndexOut);
- break;
- }
- case 2:
- {
- MEDCouplingUMesh::SetPartOfIndexedArrays(&multiVal[0],&multiVal[0]+multiVal.size(),arrIn,arrIndxIn,srcArr,srcArrIndex,arrOut,arrIndexOut);
- break;
- }
- case 4:
- {
- MEDCouplingUMesh::SetPartOfIndexedArrays(daIntTyypp->begin(),daIntTyypp->end(),arrIn,arrIndxIn,srcArr,srcArrIndex,arrOut,arrIndexOut);
- break;
- }
- default:
- throw INTERP_KERNEL::Exception("MEDCouplingUMesh::SetPartOfIndexedArrays : unrecognized type entered, expected list of int, tuple of int or DataArrayInt !");
- }
- PyObject *ret=PyTuple_New(2);
- PyTuple_SetItem(ret,0,SWIG_NewPointerObj(SWIG_as_voidptr(arrOut),SWIGTYPE_p_MEDCoupling__DataArrayInt, SWIG_POINTER_OWN | 0 ));
- PyTuple_SetItem(ret,1,SWIG_NewPointerObj(SWIG_as_voidptr(arrIndexOut),SWIGTYPE_p_MEDCoupling__DataArrayInt, SWIG_POINTER_OWN | 0 ));
- return ret;
- }
-
- static void SetPartOfIndexedArraysSameIdx(PyObject *li, DataArrayInt *arrIn, const DataArrayInt *arrIndxIn,
- const DataArrayInt *srcArr, const DataArrayInt *srcArrIndex)
- {
- int sw;
- int singleVal;
- std::vector<int> multiVal;
- std::pair<int, std::pair<int,int> > slic;
- MEDCoupling::DataArrayInt *daIntTyypp=0;
- if(!arrIndxIn)
- throw INTERP_KERNEL::Exception("MEDCouplingUMesh::SetPartOfIndexedArraysSameIdx : null pointer as arrIndex !");
- convertIntStarOrSliceLikePyObjToCpp(li,arrIndxIn->getNumberOfTuples()-1,sw,singleVal,multiVal,slic,daIntTyypp);
- switch(sw)
- {
- case 1:
- {
- MEDCouplingUMesh::SetPartOfIndexedArraysSameIdx(&singleVal,&singleVal+1,arrIn,arrIndxIn,srcArr,srcArrIndex);
- break;
- }
- case 2:
- {
- MEDCouplingUMesh::SetPartOfIndexedArraysSameIdx(&multiVal[0],&multiVal[0]+multiVal.size(),arrIn,arrIndxIn,srcArr,srcArrIndex);
- break;
- }
- case 4:
- {
- MEDCouplingUMesh::SetPartOfIndexedArraysSameIdx(daIntTyypp->begin(),daIntTyypp->end(),arrIn,arrIndxIn,srcArr,srcArrIndex);
- break;
- }
- default:
- throw INTERP_KERNEL::Exception("MEDCouplingUMesh::SetPartOfIndexedArraysSameIdx : unrecognized type entered, expected list of int, tuple of int or DataArrayInt !");
- }
- }
-
PyObject *are2DCellsNotCorrectlyOriented(PyObject *vec, bool polyOnly) const
{
double val;
self.checkConsistencyLight()
d=(self.getTypeOfField(),self.getTimeDiscretization())
return MEDCouplingStdReduceFunct,(MEDCouplingFieldFloat,(d,(self.__getstate__()),))
+
+#
+# Forwarding DataArrayInt functions to MEDCouplingUMesh:
+#
+MEDCouplingUMesh.ExtractFromIndexedArrays = DataArrayInt.ExtractFromIndexedArrays
+MEDCouplingUMesh.ExtractFromIndexedArraysSlice = DataArrayInt.ExtractFromIndexedArraysSlice
+MEDCouplingUMesh.SetPartOfIndexedArrays = DataArrayInt.SetPartOfIndexedArrays
+##MEDCouplingUMesh.SetPartOfIndexedArraysSlice = DataArrayInt.SetPartOfIndexedArraysSlice
+MEDCouplingUMesh.SetPartOfIndexedArraysSameIdx = DataArrayInt.SetPartOfIndexedArraysSameIdx
+MEDCouplingUMesh.RemoveIdsFromIndexedArrays = DataArrayInt.RemoveIdsFromIndexedArrays
+##MEDCouplingUMesh.SetPartOfIndexedArraysSameIdxSlice = DataArrayInt.SetPartOfIndexedArraysSameIdxSlice
+
%}
%pythoncode %{
PyTuple_SetItem(pyRet,1,ret1Py);
return pyRet;
}
- }
+
+ static bool RemoveIdsFromIndexedArrays(PyObject *li, DataArrayInt *arr, DataArrayInt *arrIndx, int offsetForRemoval=0) throw(INTERP_KERNEL::Exception)
+ {
+ int sw;
+ int singleVal;
+ std::vector<int> multiVal;
+ std::pair<int, std::pair<int,int> > slic;
+ MEDCoupling::DataArrayInt *daIntTyypp=0;
+ if(!arrIndx)
+ throw INTERP_KERNEL::Exception("DataArrayInt::RemoveIdsFromIndexedArrays : null pointer as arrIndex !");
+ convertIntStarOrSliceLikePyObjToCpp(li,arrIndx->getNumberOfTuples()-1,sw,singleVal,multiVal,slic,daIntTyypp);
+ switch(sw)
+ {
+ case 1:
+ return DataArrayInt::RemoveIdsFromIndexedArrays(&singleVal,&singleVal+1,arr,arrIndx,offsetForRemoval);
+ case 2:
+ return DataArrayInt::RemoveIdsFromIndexedArrays(&multiVal[0],&multiVal[0]+multiVal.size(),arr,arrIndx,offsetForRemoval);
+ case 4:
+ return DataArrayInt::RemoveIdsFromIndexedArrays(daIntTyypp->begin(),daIntTyypp->end(),arr,arrIndx,offsetForRemoval);
+ default:
+ throw INTERP_KERNEL::Exception("MEDCouplingUMesh::RemoveIdsFromIndexedArrays : unrecognized type entered, expected list of int, tuple of int or DataArrayInt !");
+ }
+ }
+
+ static PyObject *ExtractFromIndexedArrays(PyObject *li, const DataArrayInt *arrIn, const DataArrayInt *arrIndxIn) throw(INTERP_KERNEL::Exception)
+ {
+ DataArrayInt *arrOut=0,*arrIndexOut=0;
+ int sw;
+ int singleVal;
+ std::vector<int> multiVal;
+ std::pair<int, std::pair<int,int> > slic;
+ MEDCoupling::DataArrayInt *daIntTyypp=0;
+ if(!arrIndxIn)
+ throw INTERP_KERNEL::Exception("DataArrayInt::ExtractFromIndexedArrays : null pointer as arrIndxIn !");
+ convertIntStarOrSliceLikePyObjToCpp(li,arrIndxIn->getNumberOfTuples()-1,sw,singleVal,multiVal,slic,daIntTyypp);
+ switch(sw)
+ {
+ case 1:
+ {
+ DataArrayInt::ExtractFromIndexedArrays(&singleVal,&singleVal+1,arrIn,arrIndxIn,arrOut,arrIndexOut);
+ break;
+ }
+ case 2:
+ {
+ DataArrayInt::ExtractFromIndexedArrays(&multiVal[0],&multiVal[0]+multiVal.size(),arrIn,arrIndxIn,arrOut,arrIndexOut);
+ break;
+ }
+ case 4:
+ {
+ DataArrayInt::ExtractFromIndexedArrays(daIntTyypp->begin(),daIntTyypp->end(),arrIn,arrIndxIn,arrOut,arrIndexOut);
+ break;
+ }
+ default:
+ throw INTERP_KERNEL::Exception("DataArrayInt::ExtractFromIndexedArrays : unrecognized type entered, expected list of int, tuple of int or DataArrayInt !");
+ }
+ PyObject *ret=PyTuple_New(2);
+ PyTuple_SetItem(ret,0,SWIG_NewPointerObj(SWIG_as_voidptr(arrOut),SWIGTYPE_p_MEDCoupling__DataArrayInt, SWIG_POINTER_OWN | 0 ));
+ PyTuple_SetItem(ret,1,SWIG_NewPointerObj(SWIG_as_voidptr(arrIndexOut),SWIGTYPE_p_MEDCoupling__DataArrayInt, SWIG_POINTER_OWN | 0 ));
+ return ret;
+ }
+
+ static PyObject *ExtractFromIndexedArraysSlice(int strt, int stp, int step, const DataArrayInt *arrIn, const DataArrayInt *arrIndxIn) throw(INTERP_KERNEL::Exception)
+ {
+ DataArrayInt *arrOut=0,*arrIndexOut=0;
+ DataArrayInt::ExtractFromIndexedArraysSlice(strt,stp,step,arrIn,arrIndxIn,arrOut,arrIndexOut);
+ PyObject *ret=PyTuple_New(2);
+ PyTuple_SetItem(ret,0,SWIG_NewPointerObj(SWIG_as_voidptr(arrOut),SWIGTYPE_p_MEDCoupling__DataArrayInt, SWIG_POINTER_OWN | 0 ));
+ PyTuple_SetItem(ret,1,SWIG_NewPointerObj(SWIG_as_voidptr(arrIndexOut),SWIGTYPE_p_MEDCoupling__DataArrayInt, SWIG_POINTER_OWN | 0 ));
+ return ret;
+ }
+
+ static PyObject *ExtractFromIndexedArraysSlice(PyObject *slic, const DataArrayInt *arrIn, const DataArrayInt *arrIndxIn) throw(INTERP_KERNEL::Exception)
+ {
+ if(!PySlice_Check(slic))
+ throw INTERP_KERNEL::Exception("ExtractFromIndexedArraysSlice (wrap) : the first param is not a pyslice !");
+ Py_ssize_t strt=2,stp=2,step=2;
+ if(!arrIndxIn)
+ throw INTERP_KERNEL::Exception("ExtractFromIndexedArraysSlice (wrap) : last array is null !");
+ arrIndxIn->checkAllocated();
+ if(arrIndxIn->getNumberOfComponents()!=1)
+ throw INTERP_KERNEL::Exception("ExtractFromIndexedArraysSlice (wrap) : number of components of last argument must be equal to one !");
+ GetIndicesOfSlice(slic,arrIndxIn->getNumberOfTuples(),&strt,&stp,&step,"ExtractFromIndexedArraysSlice (wrap) : Invalid slice regarding nb of elements !");
+ DataArrayInt *arrOut=0,*arrIndexOut=0;
+ DataArrayInt::ExtractFromIndexedArraysSlice(strt,stp,step,arrIn,arrIndxIn,arrOut,arrIndexOut);
+ PyObject *ret=PyTuple_New(2);
+ PyTuple_SetItem(ret,0,SWIG_NewPointerObj(SWIG_as_voidptr(arrOut),SWIGTYPE_p_MEDCoupling__DataArrayInt, SWIG_POINTER_OWN | 0 ));
+ PyTuple_SetItem(ret,1,SWIG_NewPointerObj(SWIG_as_voidptr(arrIndexOut),SWIGTYPE_p_MEDCoupling__DataArrayInt, SWIG_POINTER_OWN | 0 ));
+ return ret;
+ }
+
+ static PyObject *SetPartOfIndexedArrays(PyObject *li,
+ const DataArrayInt *arrIn, const DataArrayInt *arrIndxIn,
+ const DataArrayInt *srcArr, const DataArrayInt *srcArrIndex) throw(INTERP_KERNEL::Exception)
+ {
+ DataArrayInt *arrOut=0,*arrIndexOut=0;
+ int sw;
+ int singleVal;
+ std::vector<int> multiVal;
+ std::pair<int, std::pair<int,int> > slic;
+ MEDCoupling::DataArrayInt *daIntTyypp=0;
+ if(!arrIndxIn)
+ throw INTERP_KERNEL::Exception("DataArrayInt::SetPartOfIndexedArrays : null pointer as arrIndex !");
+ convertIntStarOrSliceLikePyObjToCpp(li,arrIndxIn->getNumberOfTuples()-1,sw,singleVal,multiVal,slic,daIntTyypp);
+ switch(sw)
+ {
+ case 1:
+ {
+ DataArrayInt::SetPartOfIndexedArrays(&singleVal,&singleVal+1,arrIn,arrIndxIn,srcArr,srcArrIndex,arrOut,arrIndexOut);
+ break;
+ }
+ case 2:
+ {
+ DataArrayInt::SetPartOfIndexedArrays(&multiVal[0],&multiVal[0]+multiVal.size(),arrIn,arrIndxIn,srcArr,srcArrIndex,arrOut,arrIndexOut);
+ break;
+ }
+ case 4:
+ {
+ DataArrayInt::SetPartOfIndexedArrays(daIntTyypp->begin(),daIntTyypp->end(),arrIn,arrIndxIn,srcArr,srcArrIndex,arrOut,arrIndexOut);
+ break;
+ }
+ default:
+ throw INTERP_KERNEL::Exception("DataArrayInt::SetPartOfIndexedArrays : unrecognized type entered, expected list of int, tuple of int or DataArrayInt !");
+ }
+ PyObject *ret=PyTuple_New(2);
+ PyTuple_SetItem(ret,0,SWIG_NewPointerObj(SWIG_as_voidptr(arrOut),SWIGTYPE_p_MEDCoupling__DataArrayInt, SWIG_POINTER_OWN | 0 ));
+ PyTuple_SetItem(ret,1,SWIG_NewPointerObj(SWIG_as_voidptr(arrIndexOut),SWIGTYPE_p_MEDCoupling__DataArrayInt, SWIG_POINTER_OWN | 0 ));
+ return ret;
+ }
+
+ static void SetPartOfIndexedArraysSameIdx(PyObject *li, DataArrayInt *arrIn, const DataArrayInt *arrIndxIn,
+ const DataArrayInt *srcArr, const DataArrayInt *srcArrIndex) throw(INTERP_KERNEL::Exception)
+ {
+ int sw;
+ int singleVal;
+ std::vector<int> multiVal;
+ std::pair<int, std::pair<int,int> > slic;
+ MEDCoupling::DataArrayInt *daIntTyypp=0;
+ if(!arrIndxIn)
+ throw INTERP_KERNEL::Exception("DataArrayInt::SetPartOfIndexedArraysSameIdx : null pointer as arrIndex !");
+ convertIntStarOrSliceLikePyObjToCpp(li,arrIndxIn->getNumberOfTuples()-1,sw,singleVal,multiVal,slic,daIntTyypp);
+ switch(sw)
+ {
+ case 1:
+ {
+ DataArrayInt::SetPartOfIndexedArraysSameIdx(&singleVal,&singleVal+1,arrIn,arrIndxIn,srcArr,srcArrIndex);
+ break;
+ }
+ case 2:
+ {
+ DataArrayInt::SetPartOfIndexedArraysSameIdx(&multiVal[0],&multiVal[0]+multiVal.size(),arrIn,arrIndxIn,srcArr,srcArrIndex);
+ break;
+ }
+ case 4:
+ {
+ DataArrayInt::SetPartOfIndexedArraysSameIdx(daIntTyypp->begin(),daIntTyypp->end(),arrIn,arrIndxIn,srcArr,srcArrIndex);
+ break;
+ }
+ default:
+ throw INTERP_KERNEL::Exception("DataArrayInt::SetPartOfIndexedArraysSameIdx : unrecognized type entered, expected list of int, tuple of int or DataArrayInt !");
+ }
+ }
+
+ } // end extent
};
class DataArrayIntTuple;