X-Git-Url: http://git.salome-platform.org/gitweb/?a=blobdiff_plain;f=src%2FMEDCoupling%2FMEDCouplingPointSet.cxx;h=e3cbda93fe3d8da4024bb09b91a14b6ee5005042;hb=3567980cd75ceaee7a18ef3638310804c0e09e7c;hp=5e903305843a6ebcde4ba0e71c1d119361dce73f;hpb=6e9e6ed19073899b7ccd7179f8738f1b149b7ea1;p=modules%2Fmed.git diff --git a/src/MEDCoupling/MEDCouplingPointSet.cxx b/src/MEDCoupling/MEDCouplingPointSet.cxx index 5e9033058..e3cbda93f 100644 --- a/src/MEDCoupling/MEDCouplingPointSet.cxx +++ b/src/MEDCoupling/MEDCouplingPointSet.cxx @@ -1,9 +1,9 @@ -// Copyright (C) 2007-2013 CEA/DEN, EDF R&D +// Copyright (C) 2007-2014 CEA/DEN, EDF R&D // // This library is free software; you can redistribute it and/or // modify it under the terms of the GNU Lesser General Public // License as published by the Free Software Foundation; either -// version 2.1 of the License. +// version 2.1 of the License, or (at your option) any later version. // // This library is distributed in the hope that it will be useful, // but WITHOUT ANY WARRANTY; without even the implied warranty of @@ -80,11 +80,10 @@ std::size_t MEDCouplingPointSet::getHeapMemorySizeWithoutChildren() const return MEDCouplingMesh::getHeapMemorySizeWithoutChildren(); } -std::vector MEDCouplingPointSet::getDirectChildren() const +std::vector MEDCouplingPointSet::getDirectChildrenWithNull() const { std::vector ret; - if(_coords) - ret.push_back(_coords); + ret.push_back(_coords); return ret; } @@ -124,10 +123,10 @@ DataArrayDouble *MEDCouplingPointSet::getCoordinatesAndOwner() const */ void MEDCouplingPointSet::copyTinyStringsFrom(const MEDCouplingMesh *other) { + MEDCouplingMesh::copyTinyStringsFrom(other); const MEDCouplingPointSet *otherC=dynamic_cast(other); if(!otherC) throw INTERP_KERNEL::Exception("MEDCouplingPointSet::copyTinyStringsFrom : meshes have not same type !"); - MEDCouplingMesh::copyTinyStringsFrom(other); if(_coords && otherC->_coords) _coords->copyStringInfoFrom(*otherC->_coords); } @@ -223,8 +222,10 @@ bool MEDCouplingPointSet::areCoordsEqualWithoutConsideringStr(const MEDCouplingP * \throw If the coordinates array is not set. * \throw If \a nodeId is not a valid index for the coordinates array. * + * \if ENABLE_EXAMPLES * \ref cpp_mcpointset_getcoordinatesofnode "Here is a C++ example".
* \ref py_mcpointset_getcoordinatesofnode "Here is a Python example". + * \endif */ void MEDCouplingPointSet::getCoordinatesOfNode(int nodeId, std::vector& coo) const { @@ -293,8 +294,10 @@ DataArrayInt *MEDCouplingPointSet::buildPermArrayForMergeNode(double precision, * is to delete this array using decrRef() as it is no more needed. * \throw If the coordinates array is not set. * + * \if ENABLE_EXAMPLES * \ref cpp_mcpointset_findcommonnodes "Here is a C++ example".
* \ref py_mcpointset_findcommonnodes "Here is a Python example". + * \endif */ void MEDCouplingPointSet::findCommonNodes(double prec, int limitNodeId, DataArrayInt *&comm, DataArrayInt *&commIndex) const { @@ -315,8 +318,10 @@ void MEDCouplingPointSet::findCommonNodes(double prec, int limitNodeId, DataArra * array using decrRef() as it is no more needed. * \throw If the coordinates array is not set. * + * \if ENABLE_EXAMPLES * \ref cpp_mcpointset_getnodeidsnearpoint "Here is a C++ example".
* \ref py_mcpointset_getnodeidsnearpoint "Here is a Python example". + * \endif */ DataArrayInt *MEDCouplingPointSet::getNodeIdsNearPoint(const double *pos, double eps) const { @@ -348,8 +353,10 @@ DataArrayInt *MEDCouplingPointSet::getNodeIdsNearPoint(const double *pos, double * The caller is to delete this array using decrRef() as it is no more needed. * \throw If the coordinates array is not set. * + * \if ENABLE_EXAMPLES * \ref cpp_mcpointset_getnodeidsnearpoints "Here is a C++ example".
* \ref py_mcpointset_getnodeidsnearpoints "Here is a Python example". + * \endif */ void MEDCouplingPointSet::getNodeIdsNearPoints(const double *pos, int nbOfPoints, double eps, DataArrayInt *& c, DataArrayInt *& cI) const { @@ -386,8 +393,10 @@ DataArrayInt *MEDCouplingPointSet::buildNewNumberingFromCommonNodesFormat(const * \throw If the coordinates array is not set. * \throw If the nodal connectivity of cells is not defined. * + * \if ENABLE_EXAMPLES * \ref cpp_mcumesh_renumberNodes "Here is a C++ example".
* \ref py_mcumesh_renumberNodes "Here is a Python example". + * \endif */ void MEDCouplingPointSet::renumberNodes(const int *newNodeNumbers, int newNbOfNodes) { @@ -412,8 +421,10 @@ void MEDCouplingPointSet::renumberNodes(const int *newNodeNumbers, int newNbOfNo * \throw If the coordinates array is not set. * \throw If the nodal connectivity of cells is not defined. * + * \if ENABLE_EXAMPLES * \ref cpp_mcumesh_renumberNodes "Here is a C++ example".
* \ref py_mcumesh_renumberNodes "Here is a Python example". + * \endif */ void MEDCouplingPointSet::renumberNodes2(const int *newNodeNumbers, int newNbOfNodes) { @@ -449,8 +460,10 @@ void MEDCouplingPointSet::renumberNodes2(const int *newNodeNumbers, int newNbOfN * pre-allocated by the caller. * \throw If the coordinates array is not set. * + * \if ENABLE_EXAMPLES * \ref cpp_mcpointset_getBoundingBox "Here is a C++ example".
* \ref py_mcpointset_getBoundingBox "Here is a Python example". + * \endif */ void MEDCouplingPointSet::getBoundingBox(double *bbox) const { @@ -521,8 +534,10 @@ void MEDCouplingPointSet::recenterForMaxPrecision(double eps) * \throw If \a vector == NULL && \a this->getSpaceDimension() == 3. * \throw If Magnitude of \a vector is zero. * + * \if ENABLE_EXAMPLES * \ref cpp_mcpointset_rotate "Here is a C++ example".
* \ref py_mcpointset_rotate "Here is a Python example". + * \endif */ void MEDCouplingPointSet::rotate(const double *center, const double *vector, double angle) { @@ -544,8 +559,10 @@ void MEDCouplingPointSet::rotate(const double *center, const double *vector, dou * \throw If the coordinates array is not set. * \throw If \a vector == NULL. * + * \if ENABLE_EXAMPLES * \ref cpp_mcpointset_translate "Here is a C++ example".
* \ref py_mcpointset_translate "Here is a Python example". + * \endif */ void MEDCouplingPointSet::translate(const double *vector) { @@ -572,8 +589,10 @@ void MEDCouplingPointSet::translate(const double *vector) * \throw If the coordinates array is not set. * \throw If \a point == NULL. * + * \if ENABLE_EXAMPLES * \ref cpp_mcpointset_scale "Here is a C++ example".
* \ref py_mcpointset_scale "Here is a Python example". + * \endif */ void MEDCouplingPointSet::scale(const double *point, double factor) { @@ -1202,7 +1221,7 @@ void MEDCouplingPointSet::project2DCellOnXY(const int *startConn, const int *end { std::vector cpy(res); int nbNodes=(int)std::distance(startConn,endConn); - INTERP_KERNEL::PlanarIntersector::projection(&res[0],&cpy[0],nbNodes,nbNodes,1.e-12,0.,0.,true); + INTERP_KERNEL::PlanarIntersector::Projection(&res[0],&cpy[0],nbNodes,nbNodes,1.e-12,0./*max distance*/,-1./*min dot*/,0.,true); res.resize(2*nbNodes); for(int i=0;i * \ref py_mcumesh_buildPartOfMySelfNode "Here is a Python example". + * \endif */ MEDCouplingPointSet *MEDCouplingPointSet::buildPartOfMySelfNode(const int *begin, const int *end, bool fullyIn) const { @@ -1383,8 +1404,10 @@ MEDCouplingPointSet *MEDCouplingPointSet::buildPartOfMySelfNode(const int *begin * \throw If the nodal connectivity of cells is not defined. * \throw If the nodal connectivity includes an invalid id. * + * \if ENABLE_EXAMPLES * \ref cpp_mcumesh_zipConnectivityTraducer "Here is a C++ example".
* \ref py_mcumesh_zipConnectivityTraducer "Here is a Python example". + * \endif */ DataArrayInt *MEDCouplingPointSet::zipConnectivityTraducer(int compType, int startCellId) { @@ -1417,11 +1440,13 @@ DataArrayInt *MEDCouplingPointSet::zipConnectivityTraducer(int compType, int sta * to delete this array using decrRef() as it is no more needed. * \throw If the two meshes do not match. * + * \if ENABLE_EXAMPLES * \ref cpp_mcumesh_checkDeepEquivalWith "Here is a C++ example".
* \ref py_mcumesh_checkDeepEquivalWith "Here is a Python example". + * \endif */ void MEDCouplingPointSet::checkDeepEquivalWith(const MEDCouplingMesh *other, int cellCompPol, double prec, - DataArrayInt *&cellCor, DataArrayInt *&nodeCor) const throw(INTERP_KERNEL::Exception) + DataArrayInt *&cellCor, DataArrayInt *&nodeCor) const { if(!other) throw INTERP_KERNEL::Exception("MEDCouplingPointSet::checkDeepEquivalWith : input is null !"); @@ -1434,7 +1459,7 @@ void MEDCouplingPointSet::checkDeepEquivalWith(const MEDCouplingMesh *other, int int oldNbOfNodes=getNumberOfNodes(); MEDCouplingAutoRefCountObjectPtr da=m->buildPermArrayForMergeNode(prec,oldNbOfNodes,areNodesMerged,newNbOfNodes); //mergeNodes - if(!areNodesMerged) + if(!areNodesMerged && oldNbOfNodes != 0) throw INTERP_KERNEL::Exception("checkDeepEquivalWith : Nodes are incompatible ! "); const int *pt=std::find_if(da->getConstPointer()+oldNbOfNodes,da->getConstPointer()+da->getNbOfElems(),std::bind2nd(std::greater(),oldNbOfNodes-1)); if(pt!=da->getConstPointer()+da->getNbOfElems()) @@ -1446,12 +1471,19 @@ void MEDCouplingPointSet::checkDeepEquivalWith(const MEDCouplingMesh *other, int // da=m->zipConnectivityTraducer(cellCompPol); int nbCells=getNumberOfCells(); - int maxId=-1; - if(nbCells!=0) - maxId=*std::max_element(da->getConstPointer(),da->getConstPointer()+nbCells); - pt=std::find_if(da->getConstPointer()+nbCells,da->getConstPointer()+da->getNbOfElems(),std::bind2nd(std::greater(),maxId)); - if(pt!=da->getConstPointer()+da->getNbOfElems()) + if (nbCells != other->getNumberOfCells()) throw INTERP_KERNEL::Exception("checkDeepEquivalWith : some cells in other are not in this !"); + int dan(da->getNumberOfTuples()); + if (dan) + { + MEDCouplingAutoRefCountObjectPtr da1(DataArrayInt::New()),da2(DataArrayInt::New()); + da1->alloc(dan/2,1); da2->alloc(dan/2,1); + std::copy(da->getConstPointer(), da->getConstPointer()+dan/2, da1->getPointer()); + std::copy(da->getConstPointer()+dan/2, da->getConstPointer()+dan, da2->getPointer()); + da1->sort(); da2->sort(); + if (!da1->isEqualWithoutConsideringStr(*da2)) + throw INTERP_KERNEL::Exception("checkDeepEquivalWith : some cells in other are not in this !"); + } MEDCouplingAutoRefCountObjectPtr cellCor2=da->selectByTupleId2(nbCells,da->getNbOfElems(),1); nodeCor=nodeCor2->isIdentity()?0:nodeCor2.retn(); cellCor=cellCor2->isIdentity()?0:cellCor2.retn(); @@ -1471,11 +1503,13 @@ void MEDCouplingPointSet::checkDeepEquivalWith(const MEDCouplingMesh *other, int * to delete this array using decrRef() as it is no more needed. * \throw If the two meshes do not match. * + * \if ENABLE_EXAMPLES * \ref cpp_mcumesh_checkDeepEquivalWith "Here is a C++ example".
* \ref py_mcumesh_checkDeepEquivalWith "Here is a Python example". + * \endif */ void MEDCouplingPointSet::checkDeepEquivalOnSameNodesWith(const MEDCouplingMesh *other, int cellCompPol, double prec, - DataArrayInt *&cellCor) const throw(INTERP_KERNEL::Exception) + DataArrayInt *&cellCor) const { if(!other) throw INTERP_KERNEL::Exception("MEDCouplingPointSet::checkDeepEquivalOnSameNodesWith : input is null !"); @@ -1530,8 +1564,10 @@ void MEDCouplingPointSet::checkFastEquivalWith(const MEDCouplingMesh *other, dou * * \sa MEDCouplingPointSet::getCellIdsFullyIncludedInNodeIds * + * \if ENABLE_EXAMPLES * \ref cpp_mcumesh_getCellIdsLyingOnNodes "Here is a C++ example".
* \ref py_mcumesh_getCellIdsLyingOnNodes "Here is a Python example". + * \endif */ DataArrayInt *MEDCouplingPointSet::getCellIdsLyingOnNodes(const int *begin, const int *end, bool fullyIn) const { @@ -1556,8 +1592,10 @@ DataArrayInt *MEDCouplingPointSet::getCellIdsLyingOnNodes(const int *begin, cons * * \sa MEDCouplingPointSet::getCellIdsLyingOnNodes * + * \if ENABLE_EXAMPLES * \ref cpp_mcumesh_getCellIdsFullyIncludedInNodeIds "Here is a C++ example".
* \ref py_mcumesh_getCellIdsFullyIncludedInNodeIds "Here is a Python example". + * \endif */ DataArrayInt *MEDCouplingPointSet::getCellIdsFullyIncludedInNodeIds(const int *partBg, const int *partEnd) const { @@ -1575,8 +1613,10 @@ DataArrayInt *MEDCouplingPointSet::getCellIdsFullyIncludedInNodeIds(const int *p * \throw If the nodal connectivity of cells is not defined. * \throw If the nodal connectivity includes an invalid id. * + * \if ENABLE_EXAMPLES * \ref cpp_mcumesh_zipCoordsTraducer "Here is a C++ example".
* \ref py_mcumesh_zipCoordsTraducer "Here is a Python example". + * \endif */ DataArrayInt *MEDCouplingPointSet::zipCoordsTraducer() { @@ -1599,8 +1639,10 @@ DataArrayInt *MEDCouplingPointSet::zipCoordsTraducer() * \throw If the coordinates array is not set. * \throw If the nodal connectivity of cells is not defined. * + * \if ENABLE_EXAMPLES * \ref cpp_mcumesh_mergeNodes "Here is a C++ example".
* \ref py_mcumesh_mergeNodes "Here is a Python example". + * \endif */ DataArrayInt *MEDCouplingPointSet::mergeNodes(double precision, bool& areNodesMerged, int& newNbOfNodes) { @@ -1624,8 +1666,10 @@ DataArrayInt *MEDCouplingPointSet::mergeNodes(double precision, bool& areNodesMe * \throw If the coordinates array is not set. * \throw If the nodal connectivity of cells is not defined. * + * \if ENABLE_EXAMPLES * \ref cpp_mcumesh_mergeNodes "Here is a C++ example".
* \ref py_mcumesh_mergeNodes "Here is a Python example". + * \endif */ DataArrayInt *MEDCouplingPointSet::mergeNodes2(double precision, bool& areNodesMerged, int& newNbOfNodes) {