/*!
* This method is equivalent to MEDCouplingMesh::buildPart method except that here the cell ids are specified using slice \a beginCellIds \a endCellIds and \a stepCellIds.
+ * \b WARNING , there is a big difference compared to MEDCouplingMesh::buildPart method.
+ * If the input range is equal all cells in \a this, \a this is returned !
+ *
+ * \return a new ref to be managed by the caller. Warning this ref can be equal to \a this if input slice is exactly equal to the whole cells in the same order.
*
* \sa MEDCouplingMesh::buildPart
*/
MEDCouplingMesh *MEDCouplingMesh::buildPartRange(int beginCellIds, int endCellIds, int stepCellIds) const throw(INTERP_KERNEL::Exception)
{
- MEDCouplingAutoRefCountObjectPtr<DataArrayInt> cellIds=DataArrayInt::Range(beginCellIds,endCellIds,stepCellIds);
- return buildPart(cellIds->begin(),cellIds->end());
+ if(beginCellIds==0 && endCellIds==getNumberOfCells() && stepCellIds==1)
+ {
+ MEDCouplingMesh *ret(const_cast<MEDCouplingMesh *>(this));
+ ret->incrRef();
+ return ret;
+ }
+ else
+ {
+ MEDCouplingAutoRefCountObjectPtr<DataArrayInt> cellIds=DataArrayInt::Range(beginCellIds,endCellIds,stepCellIds);
+ return buildPart(cellIds->begin(),cellIds->end());
+ }
}
/*!
}
/*!
- * This method specialized the MEDCouplingMesh::buildPartRange
+ * This method specialized the MEDCouplingMesh::buildPartRange.
+ * This method is equivalent to MEDCouplingMesh::buildPart method except that here the cell ids are specified using slice
+ * \a beginCellIds \a endCellIds and \a stepCellIds.
+ * \b WARNING , there is a big difference compared to MEDCouplingMesh::buildPart method.
+ * If the input range is equal all cells in \a this, \a this is returned !
+ *
+ * \return a new ref to be managed by the caller. Warning this ref can be equal to \a this if input slice is exactly equal to the whole cells in the same order.
*
* \sa MEDCouplingUMesh::buildPartOfMySelf2
*/
MEDCouplingMesh *MEDCouplingPointSet::buildPartRange(int beginCellIds, int endCellIds, int stepCellIds) const throw(INTERP_KERNEL::Exception)
{
- return buildPartOfMySelf2(beginCellIds,endCellIds,stepCellIds,true);
+ if(beginCellIds==0 && endCellIds==getNumberOfCells() && stepCellIds==1)
+ {
+ MEDCouplingMesh *ret(const_cast<MEDCouplingPointSet *>(this));
+ ret->incrRef();
+ return ret;
+ }
+ else
+ {
+ return buildPartOfMySelf2(beginCellIds,endCellIds,stepCellIds,true);
+ }
}
/*!
pass
#
pass
+
+ # test the when input slice is all the same object is return by MEDCouplingMesh.buildPartRange
+ def testSwig2MeshPartSlice1(self):
+ a=DataArrayDouble(4) ; a.iota()
+ c=MEDCouplingCMesh() ; c.setCoords(a,a) ; m=c.buildUnstructured()
+ fc0=c.getMeasureField(False) ; fc1=fc0[:] ; fc2=fc0*fc1 ; fc2.setName(fc0.getName())
+ self.assertEqual(fc0.getMesh().getHiddenCppPointer(),fc1.getMesh().getHiddenCppPointer())
+ self.assertEqual(fc2.getMesh().getHiddenCppPointer(),fc1.getMesh().getHiddenCppPointer())
+ self.assertTrue(fc2.isEqual(fc1,1e-12,1e-12))
+ #
+ fm0=m.getMeasureField(False) ; fm1=fm0[:] ; fm2=fm0*fm1 ; fm2.setName(fm0.getName())
+ self.assertEqual(fm0.getMesh().getHiddenCppPointer(),fm1.getMesh().getHiddenCppPointer())
+ self.assertEqual(fm2.getMesh().getHiddenCppPointer(),fm1.getMesh().getHiddenCppPointer())
+ self.assertTrue(fm2.isEqual(fm1,1e-12,1e-12))
+ pass
def setUp(self):
pass