throw INTERP_KERNEL::Exception("A value 0.0 have been detected !");
}
+/*!
+ * This method assume that \b this is allocated. If not an INTERP_KERNEL::Exception will be thrown.
+ * This method fills \b bounds params like that : \b bounds[0]=XMin, \b bounds[1]=XMax, \b bounds[2]=YMin, \b bounds[3]=YMax...
+ * Where X refers to component #0, and Y to component #1...
+ * This method set 2*this->getNumberOfComponents() elements in \b bounds, so it is up to the caller to allocated enough space before calling this method.
+ *
+ * @param [out] bounds array of size 2*this->getNumberOfComponents().
+ */
+void DataArrayDouble::getMinMaxPerComponent(double *bounds) const throw(INTERP_KERNEL::Exception)
+{
+ checkAllocated();
+ int dim=getNumberOfComponents();
+ for (int idim=0; idim<dim; idim++)
+ {
+ bounds[idim*2]=std::numeric_limits<double>::max();
+ bounds[idim*2+1]=-std::numeric_limits<double>::max();
+ }
+ const double *ptr=getConstPointer();
+ int nbOfTuples=getNumberOfTuples();
+ for(int i=0;i<nbOfTuples;i++)
+ {
+ for(int idim=0;idim<dim;idim++)
+ {
+ if(bounds[idim*2]>ptr[i*dim+idim])
+ {
+ bounds[idim*2]=ptr[i*dim+idim];
+ }
+ if(bounds[idim*2+1]<ptr[i*dim+idim])
+ {
+ bounds[idim*2+1]=ptr[i*dim+idim];
+ }
+ }
+ }
+}
+
double DataArrayDouble::getMaxValue(int& tupleId) const throw(INTERP_KERNEL::Exception)
{
if(getNumberOfComponents()!=1)
MEDCOUPLING_EXPORT void useArray(const double *array, bool ownership, DeallocType type, int nbOfTuple, int nbOfCompo);
MEDCOUPLING_EXPORT void writeOnPlace(int id, double element0, const double *others, int sizeOfOthers) { _mem.writeOnPlace(id,element0,others,sizeOfOthers); }
MEDCOUPLING_EXPORT void checkNoNullValues() const throw(INTERP_KERNEL::Exception);
+ MEDCOUPLING_EXPORT void getMinMaxPerComponent(double *bounds) const throw(INTERP_KERNEL::Exception);
MEDCOUPLING_EXPORT double getMaxValue(int& tupleId) const throw(INTERP_KERNEL::Exception);
MEDCOUPLING_EXPORT double getMaxValueInArray() const throw(INTERP_KERNEL::Exception);
MEDCOUPLING_EXPORT double getMinValue(int& tupleId) const throw(INTERP_KERNEL::Exception);
* The returned bounding box is arranged along trihedron.
* @param bbox out array of size 2*this->getSpaceDimension().
*/
-void MEDCouplingPointSet::getBoundingBox(double *bbox) const
+void MEDCouplingPointSet::getBoundingBox(double *bbox) const throw(INTERP_KERNEL::Exception)
{
- int dim=getSpaceDimension();
- for (int idim=0; idim<dim; idim++)
- {
- bbox[idim*2]=std::numeric_limits<double>::max();
- bbox[idim*2+1]=-std::numeric_limits<double>::max();
- }
- const double *coords=_coords->getConstPointer();
- int nbnodes=getNumberOfNodes();
- for (int i=0; i<nbnodes; i++)
- {
- for (int idim=0; idim<dim;idim++)
- {
- if ( bbox[idim*2] > coords[i*dim+idim] )
- {
- bbox[idim*2] = coords[i*dim+idim] ;
- }
- if ( bbox[idim*2+1] < coords[i*dim+idim] )
- {
- bbox[idim*2+1] = coords[i*dim+idim] ;
- }
- }
- }
+ if(!_coords)
+ throw INTERP_KERNEL::Exception("MEDCouplingPointSet::getBoundingBox : Coordinates not set !");
+ _coords->getMinMaxPerComponent(bbox);
}
/*!
void findCommonNodes(double prec, int limitNodeId, DataArrayInt *&comm, DataArrayInt *&commIndex) const;
DataArrayInt *buildNewNumberingFromCommonNodesFormat(const DataArrayInt *comm, const DataArrayInt *commIndex,
int& newNbOfNodes) const;
- void getBoundingBox(double *bbox) const;
+ void getBoundingBox(double *bbox) const throw(INTERP_KERNEL::Exception);
void zipCoords();
double getCaracteristicDimension() const;
void rotate(const double *center, const double *vector, double angle);
PyObject *getBoundingBox() const throw(INTERP_KERNEL::Exception)
{
int spaceDim=self->getSpaceDimension();
- double *tmp=new double[2*spaceDim];
+ INTERP_KERNEL::AutoPtr<double> tmp=new double[2*spaceDim];
self->getBoundingBox(tmp);
PyObject *ret=convertDblArrToPyListOfTuple(tmp,2,spaceDim);
- delete [] tmp;
return ret;
}
return ret;
}
+ PyObject *getMinMaxPerComponent() const throw(INTERP_KERNEL::Exception)
+ {
+ int nbOfCompo=self->getNumberOfComponents();
+ INTERP_KERNEL::AutoPtr<double> tmp=new double[2*nbOfCompo];
+ self->getMinMaxPerComponent(tmp);
+ PyObject *ret=convertDblArrToPyListOfTuple(tmp,2,nbOfCompo);
+ return ret;
+ }
+
PyObject *accumulate() const throw(INTERP_KERNEL::Exception)
{
int sz=self->getNumberOfComponents();