}
}
+/*!
+ * 'this', 'a' and 'tuplesSelec' are expected to be defined. If not an exception will be thrown.
+ * @param a is an array having exactly the same number of components than 'this'
+ * @param tuplesSelec is an array having exactly 2 components. The first one refers to the tuple ids of 'this' that will be set. The second one refers to the tuple ids of 'a' that will be used for setting.
+ */
+void DataArrayDouble::setPartOfValuesAdv(const DataArrayDouble *a, const DataArrayInt *tuplesSelec) throw(INTERP_KERNEL::Exception)
+{
+ checkAllocated();
+ a->checkAllocated();
+ tuplesSelec->checkAllocated();
+ int nbOfComp=getNumberOfComponents();
+ if(nbOfComp!=a->getNumberOfComponents())
+ throw INTERP_KERNEL::Exception("DataArrayDouble::setPartOfValuesAdv : This and a do not have the same number of components !");
+ if(tuplesSelec->getNumberOfComponents()!=2)
+ throw INTERP_KERNEL::Exception("DataArrayDouble::setPartOfValuesAdv : Expecting to have a tuple selector DataArrayInt instance with exactly 2 components !");
+ int thisNt=getNumberOfTuples();
+ int aNt=a->getNumberOfTuples();
+ double *valsToSet=getPointer();
+ const double *valsSrc=a->getConstPointer();
+ for(const int *tuple=tuplesSelec->begin();tuple!=tuplesSelec->end();tuple+=2)
+ {
+ if(tuple[1]>=0 && tuple[1]<aNt)
+ {
+ if(tuple[0]>=0 && tuple[0]<thisNt)
+ std::copy(valsSrc+nbOfComp*tuple[1],valsSrc+nbOfComp*(tuple[1]+1),valsToSet+nbOfComp*tuple[0]);
+ else
+ {
+ std::ostringstream oss; oss << "DataArrayDouble::setPartOfValuesAdv : Tuple #" << std::distance(tuplesSelec->begin(),tuple)/2;
+ oss << " of 'tuplesSelec' request of tuple id #" << tuple[0] << " in 'this' ! It should be in [0," << thisNt << ") !";
+ throw INTERP_KERNEL::Exception(oss.str().c_str());
+ }
+ }
+ else
+ {
+ std::ostringstream oss; oss << "DataArrayDouble::setPartOfValuesAdv : Tuple #" << std::distance(tuplesSelec->begin(),tuple)/2;
+ oss << " of 'tuplesSelec' request of tuple id #" << tuple[1] << " in 'a' ! It should be in [0," << aNt << ") !";
+ throw INTERP_KERNEL::Exception(oss.str().c_str());
+ }
+ }
+}
+
void DataArrayDouble::SetArrayIn(DataArrayDouble *newArray, DataArrayDouble* &arrayToSet)
{
if(newArray!=arrayToSet)
}
}
+/*!
+ * 'this', 'a' and 'tuplesSelec' are expected to be defined. If not an exception will be thrown.
+ * @param a is an array having exactly the same number of components than 'this'
+ * @param tuplesSelec is an array having exactly 2 components. The first one refers to the tuple ids of 'this' that will be set. The second one refers to the tuple ids of 'a' that will be used for setting.
+ */
+void DataArrayInt::setPartOfValuesAdv(const DataArrayInt *a, const DataArrayInt *tuplesSelec) throw(INTERP_KERNEL::Exception)
+{
+ checkAllocated();
+ a->checkAllocated();
+ tuplesSelec->checkAllocated();
+ int nbOfComp=getNumberOfComponents();
+ if(nbOfComp!=a->getNumberOfComponents())
+ throw INTERP_KERNEL::Exception("DataArrayInt::setPartOfValuesAdv : This and a do not have the same number of components !");
+ if(tuplesSelec->getNumberOfComponents()!=2)
+ throw INTERP_KERNEL::Exception("DataArrayInt::setPartOfValuesAdv : Expecting to have a tuple selector DataArrayInt instance with exactly 2 components !");
+ int thisNt=getNumberOfTuples();
+ int aNt=a->getNumberOfTuples();
+ int *valsToSet=getPointer();
+ const int *valsSrc=a->getConstPointer();
+ for(const int *tuple=tuplesSelec->begin();tuple!=tuplesSelec->end();tuple+=2)
+ {
+ if(tuple[1]>=0 && tuple[1]<aNt)
+ {
+ if(tuple[0]>=0 && tuple[0]<thisNt)
+ std::copy(valsSrc+nbOfComp*tuple[1],valsSrc+nbOfComp*(tuple[1]+1),valsToSet+nbOfComp*tuple[0]);
+ else
+ {
+ std::ostringstream oss; oss << "DataArrayInt::setPartOfValuesAdv : Tuple #" << std::distance(tuplesSelec->begin(),tuple)/2;
+ oss << " of 'tuplesSelec' request of tuple id #" << tuple[0] << " in 'this' ! It should be in [0," << thisNt << ") !";
+ throw INTERP_KERNEL::Exception(oss.str().c_str());
+ }
+ }
+ else
+ {
+ std::ostringstream oss; oss << "DataArrayInt::setPartOfValuesAdv : Tuple #" << std::distance(tuplesSelec->begin(),tuple)/2;
+ oss << " of 'tuplesSelec' request of tuple id #" << tuple[1] << " in 'a' ! It should be in [0," << aNt << ") !";
+ throw INTERP_KERNEL::Exception(oss.str().c_str());
+ }
+ }
+}
+
void DataArrayInt::SetArrayIn(DataArrayInt *newArray, DataArrayInt* &arrayToSet)
{
if(newArray!=arrayToSet)
MEDCOUPLING_EXPORT void setPartOfValuesSimple2(double a, const int *bgTuples, const int *endTuples, const int *bgComp, const int *endComp) throw(INTERP_KERNEL::Exception);
MEDCOUPLING_EXPORT void setPartOfValues3(const DataArrayDouble *a, const int *bgTuples, const int *endTuples, int bgComp, int endComp, int stepComp, bool strictCompoCompare=true) throw(INTERP_KERNEL::Exception);
MEDCOUPLING_EXPORT void setPartOfValuesSimple3(double a, const int *bgTuples, const int *endTuples, int bgComp, int endComp, int stepComp) throw(INTERP_KERNEL::Exception);
+ MEDCOUPLING_EXPORT void setPartOfValuesAdv(const DataArrayDouble *a, const DataArrayInt *tuplesSelec) throw(INTERP_KERNEL::Exception);
MEDCOUPLING_EXPORT void getTuple(int tupleId, double *res) const { std::copy(_mem.getConstPointerLoc(tupleId*_info_on_compo.size()),_mem.getConstPointerLoc((tupleId+1)*_info_on_compo.size()),res); }
MEDCOUPLING_EXPORT double getIJ(int tupleId, int compoId) const { return _mem[tupleId*_info_on_compo.size()+compoId]; }
MEDCOUPLING_EXPORT void setIJ(int tupleId, int compoId, double newVal) { _mem[tupleId*_info_on_compo.size()+compoId]=newVal; declareAsNew(); }
MEDCOUPLING_EXPORT void setPartOfValuesSimple2(int a, const int *bgTuples, const int *endTuples, const int *bgComp, const int *endComp) throw(INTERP_KERNEL::Exception);
MEDCOUPLING_EXPORT void setPartOfValues3(const DataArrayInt *a, const int *bgTuples, const int *endTuples, int bgComp, int endComp, int stepComp, bool strictCompoCompare=true) throw(INTERP_KERNEL::Exception);
MEDCOUPLING_EXPORT void setPartOfValuesSimple3(int a, const int *bgTuples, const int *endTuples, int bgComp, int endComp, int stepComp) throw(INTERP_KERNEL::Exception);
+ MEDCOUPLING_EXPORT void setPartOfValuesAdv(const DataArrayInt *a, const DataArrayInt *tuplesSelec) throw(INTERP_KERNEL::Exception);
MEDCOUPLING_EXPORT void getTuple(int tupleId, int *res) const { std::copy(_mem.getConstPointerLoc(tupleId*_info_on_compo.size()),_mem.getConstPointerLoc((tupleId+1)*_info_on_compo.size()),res); }
MEDCOUPLING_EXPORT int getIJ(int tupleId, int compoId) const { return _mem[tupleId*_info_on_compo.size()+compoId]; }
MEDCOUPLING_EXPORT void setIJ(int tupleId, int compoId, int newVal) { _mem[tupleId*_info_on_compo.size()+compoId]=newVal; declareAsNew(); }
bary->decrRef();
f2->decrRef();
}
+
+void MEDCouplingBasicsTest4::testDaDSetPartOfValuesAdv1()
+{
+ const double tab1[18]={3.,4.,5., 13.,14.,15., 23.,24.,25., 33.,34.,35., 43.,44.,45., 53.,54.,55.};
+ const double tab2[9]={6.,7.,8., 16.,17.,18., 26.,27.,28.};
+ const int tab3[6]={4,1, 2,2, 3,0};
+ DataArrayDouble *a=DataArrayDouble::New();
+ a->alloc(6,3);
+ std::copy(tab1,tab1+18,a->getPointer());
+ DataArrayDouble *b=DataArrayDouble::New();
+ b->alloc(3,3);
+ std::copy(tab2,tab2+9,b->getPointer());
+ DataArrayInt *c=DataArrayInt::New();
+ c->alloc(3,2);
+ std::copy(tab3,tab3+6,c->getPointer());
+ //
+ a->setPartOfValuesAdv(b,c);
+ const double expected1[18]={3.,4.,5., 13.,14.,15., 26.,27.,28., 6.,7.,8., 16.,17.,18., 53.,54.,55.};
+ std::equal(expected1,expected1+18,a->getConstPointer());
+ //
+ a->decrRef();
+ b->decrRef();
+ c->decrRef();
+}
CPPUNIT_TEST( testFindAndCorrectBadOriented3DExtrudedCells1 );
CPPUNIT_TEST( testConvertExtrudedPolyhedra1 );
CPPUNIT_TEST( testNonRegressionCopyTinyStrings );
+ CPPUNIT_TEST( testDaDSetPartOfValuesAdv1 );
CPPUNIT_TEST_SUITE_END();
public:
void testDescriptionInMeshTimeUnit1();
void testFindAndCorrectBadOriented3DExtrudedCells1();
void testConvertExtrudedPolyhedra1();
void testNonRegressionCopyTinyStrings();
+ void testDaDSetPartOfValuesAdv1();
};
}
f2.setArray(bary)
self.assertRaises(InterpKernelException,f2.copyTinyAttrFrom,f1)
pass
+
+ def testDaDSetPartOfValuesAdv1(self):
+ tab1=[3.,4.,5., 13.,14.,15., 23.,24.,25., 33.,34.,35., 43.,44.,45., 53.,54.,55.]
+ tab2=[6.,7.,8., 16.,17.,18., 26.,27.,28.]
+ tab3=[4,1, 2,2, 3,0]
+ a=DataArrayDouble.New();
+ a.setValues(tab1,6,3);
+ b=DataArrayDouble.New();
+ b.setValues(tab2,3,3);
+ c=DataArrayInt.New();
+ c.setValues(tab3,3,2);
+ #
+ a.setPartOfValuesAdv(b,c);
+ expected1=[3.,4.,5., 13.,14.,15., 26.,27.,28., 6.,7.,8., 16.,17.,18., 53.,54.,55.]
+ self.assertEqual(expected1,a.getValues());
+ pass
def setUp(self):
pass