//
// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
//
+// Author : Anthony Geay (CEA/DEN)
#include "MEDCouplingPointSet.hxx"
#include "MEDCouplingAutoRefCountObjectPtr.hxx"
}
}
+std::size_t MEDCouplingPointSet::getHeapMemorySize() const
+{
+ std::size_t ret=0;
+ if(_coords)
+ ret+=_coords->getHeapMemorySize();
+ return MEDCouplingMesh::getHeapMemorySize()+ret;
+}
+
void MEDCouplingPointSet::setCoords(const DataArrayDouble *coords)
{
if( coords != _coords )
_coords->findCommonTuples(prec,limitNodeId,comm,commIndex);
}
-std::vector<int> MEDCouplingPointSet::getNodeIdsNearPoint(const double *pos, double eps) const throw(INTERP_KERNEL::Exception)
+DataArrayInt *MEDCouplingPointSet::getNodeIdsNearPoint(const double *pos, double eps) const throw(INTERP_KERNEL::Exception)
{
- std::vector<int> c,cI;
+ DataArrayInt *c=0,*cI=0;
getNodeIdsNearPoints(pos,1,eps,c,cI);
+ MEDCouplingAutoRefCountObjectPtr<DataArrayInt> cITmp(cI);
return c;
}
* Position 'pos' is expected to be of size getSpaceDimension()*nbOfNodes. If not the behabiour is not warranted.
* This method throws an exception if no coordiantes are set.
*/
-void MEDCouplingPointSet::getNodeIdsNearPoints(const double *pos, int nbOfNodes, double eps, std::vector<int>& c, std::vector<int>& cI) const throw(INTERP_KERNEL::Exception)
+void MEDCouplingPointSet::getNodeIdsNearPoints(const double *pos, int nbOfNodes, double eps, DataArrayInt *& c, DataArrayInt *& cI) const throw(INTERP_KERNEL::Exception)
{
if(!_coords)
throw INTERP_KERNEL::Exception("MEDCouplingPointSet::getNodeIdsNearPoint : no coordiantes set !");
{
if(!_coords)
throw INTERP_KERNEL::Exception("MEDCouplingPointSet::buildNewNumberingFromCommonNodesFormat : no coords specified !");
- return DataArrayInt::BuildOld2NewArrayFromSurjectiveFormat2(getNumberOfNodes(),comm,commIndex,newNbOfNodes);
+ return DataArrayInt::BuildOld2NewArrayFromSurjectiveFormat2(getNumberOfNodes(),comm->begin(),commIndex->begin(),commIndex->end(),newNbOfNodes);
}
/*
*/
void MEDCouplingPointSet::translate(const double *vector)
{
+ if(!vector)
+ throw INTERP_KERNEL::Exception("MEDCouplingPointSet::translate : NULL input vector !");
+ if(!_coords)
+ throw INTERP_KERNEL::Exception("MEDCouplingPointSet::translate : no coordinates set !");
double *coords=_coords->getPointer();
int nbNodes=getNumberOfNodes();
int dim=getSpaceDimension();
*/
void MEDCouplingPointSet::scale(const double *point, double factor)
{
+ if(!point)
+ throw INTERP_KERNEL::Exception("MEDCouplingPointSet::scale : NULL input point !");
+ if(!_coords)
+ throw INTERP_KERNEL::Exception("MEDCouplingPointSet::scale : no coordinates set !");
double *coords=_coords->getPointer();
int nbNodes=getNumberOfNodes();
int dim=getSpaceDimension();
- double *tmp=new double[dim];
for(int i=0;i<nbNodes;i++)
{
std::transform(coords+i*dim,coords+(i+1)*dim,point,coords+i*dim,std::minus<double>());
std::transform(coords+i*dim,coords+(i+1)*dim,coords+i*dim,std::bind2nd(std::multiplies<double>(),factor));
std::transform(coords+i*dim,coords+(i+1)*dim,point,coords+i*dim,std::plus<double>());
}
- delete [] tmp;
_coords->declareAsNew();
updateTime();
}
}
}
+void MEDCouplingPointSet::checkCoherency() const throw(INTERP_KERNEL::Exception)
+{
+ if(!_coords)
+ throw INTERP_KERNEL::Exception("MEDCouplingPointSet::checkCoherency : no coordinates set !");
+}
+
/*!
* Intersect Bounding Box given 2 Bounding Boxes.
*/
double matrix[9];
double matrixTmp[9];
double norm=sqrt(vect[0]*vect[0]+vect[1]*vect[1]+vect[2]*vect[2]);
+ if(norm<std::numeric_limits<double>::min())
+ throw INTERP_KERNEL::Exception("MEDCouplingPointSet::Rotate3DAlg : magnitude of input vector is too close of 0. !");
std::transform(vect,vect+3,vectorNorm,std::bind2nd(std::multiplies<double>(),1/norm));
//rotation matrix computation
matrix[0]=cosa; matrix[1]=0.; matrix[2]=0.; matrix[3]=0.; matrix[4]=cosa; matrix[5]=0.; matrix[6]=0.; matrix[7]=0.; matrix[8]=cosa;
* This method build a part of 'this' by simply keeping cells whose ids are in ['start','end') \b and potentially reduces the nodes set
* behind returned mesh. This cause an overhead but it is lesser in memory.
* This method returns an array too. This array allows to the caller to know the mapping between nodeids in 'this' and nodeids in
- * returned mesh. This is quite usefull for MEDCouplingFieldDouble on nodes for example...
+ * returned mesh. This is quite useful for MEDCouplingFieldDouble on nodes for example...
* 'arr' is in old2New format of size ret->getNumberOfCells like MEDCouplingUMesh::zipCoordsTraducer is.
* The returned mesh has to be managed by the caller.
*/