From: ageay Date: Fri, 27 Apr 2012 14:58:16 +0000 (+0000) Subject: Some clean-up X-Git-Tag: TRIPOLI_323~1 X-Git-Url: http://git.salome-platform.org/gitweb/?a=commitdiff_plain;h=050d1feee422a66a3013b8fb4506a83fb099c6b9;p=tools%2Fmedcoupling.git Some clean-up --- diff --git a/src/MEDCoupling/MEDCouplingMemArray.cxx b/src/MEDCoupling/MEDCouplingMemArray.cxx index 03492743b..4a3022687 100644 --- a/src/MEDCoupling/MEDCouplingMemArray.cxx +++ b/src/MEDCoupling/MEDCouplingMemArray.cxx @@ -1487,6 +1487,41 @@ void DataArrayDouble::checkNoNullValues() const throw(INTERP_KERNEL::Exception) 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::max(); + bounds[idim*2+1]=-std::numeric_limits::max(); + } + const double *ptr=getConstPointer(); + int nbOfTuples=getNumberOfTuples(); + for(int i=0;iptr[i*dim+idim]) + { + bounds[idim*2]=ptr[i*dim+idim]; + } + if(bounds[idim*2+1]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::max(); - bbox[idim*2+1]=-std::numeric_limits::max(); - } - const double *coords=_coords->getConstPointer(); - int nbnodes=getNumberOfNodes(); - for (int i=0; i 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); } /*! diff --git a/src/MEDCoupling/MEDCouplingPointSet.hxx b/src/MEDCoupling/MEDCouplingPointSet.hxx index 257af5247..43e723594 100644 --- a/src/MEDCoupling/MEDCouplingPointSet.hxx +++ b/src/MEDCoupling/MEDCouplingPointSet.hxx @@ -73,7 +73,7 @@ namespace ParaMEDMEM 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); diff --git a/src/MEDCoupling_Swig/MEDCoupling.i b/src/MEDCoupling_Swig/MEDCoupling.i index 744c4697f..06f91d67b 100644 --- a/src/MEDCoupling_Swig/MEDCoupling.i +++ b/src/MEDCoupling_Swig/MEDCoupling.i @@ -539,10 +539,9 @@ namespace ParaMEDMEM PyObject *getBoundingBox() const throw(INTERP_KERNEL::Exception) { int spaceDim=self->getSpaceDimension(); - double *tmp=new double[2*spaceDim]; + INTERP_KERNEL::AutoPtr tmp=new double[2*spaceDim]; self->getBoundingBox(tmp); PyObject *ret=convertDblArrToPyListOfTuple(tmp,2,spaceDim); - delete [] tmp; return ret; } @@ -2386,6 +2385,15 @@ namespace ParaMEDMEM return ret; } + PyObject *getMinMaxPerComponent() const throw(INTERP_KERNEL::Exception) + { + int nbOfCompo=self->getNumberOfComponents(); + INTERP_KERNEL::AutoPtr 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();