//
// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
//
-// Author : Anthony Geay (CEA/DEN)
+// Author : Anthony Geay (EDF R&D)
-#include "MEDCoupling1GTUMesh.hxx"
+#include "MEDCoupling1GTUMesh.txx"
#include "MEDCouplingUMesh.hxx"
#include "MEDCouplingFieldDouble.hxx"
#include "MEDCouplingCMesh.hxx"
*/
void MEDCoupling1SGTUMesh::renumberNodesInConn(const INTERP_KERNEL::HashMap<int,int>& newNodeNumbersO2N)
{
- getNumberOfCells();//only to check that all is well defined.
- int *begPtr(_conn->getPointer());
- int nbElt(_conn->getNumberOfTuples());
- int *endPtr(begPtr+nbElt);
- for(int *it=begPtr;it!=endPtr;it++)
- {
- INTERP_KERNEL::HashMap<int,int>::const_iterator it2(newNodeNumbersO2N.find(*it));
- if(it2!=newNodeNumbersO2N.end())
- {
- *it=(*it2).second;
- }
- else
- {
- std::ostringstream oss; oss << "MEDCoupling1SGTUMesh::renumberNodesInConn : At pos #" << std::distance(begPtr,it) << " of nodal connectivity value is " << *it << ". Not in map !";
- throw INTERP_KERNEL::Exception(oss.str().c_str());
- }
- }
- updateTime();
+ this->renumberNodesInConnT< INTERP_KERNEL::HashMap<int,int> >(newNodeNumbersO2N);
+}
+
+/*!
+ * Same than renumberNodesInConn(const int *) except that here the format of old-to-new traducer is using map instead
+ * of array. This method is dedicated for renumbering from a big set of nodes the a tiny set of nodes which is the case during extraction
+ * of a big mesh.
+ */
+void MEDCoupling1SGTUMesh::renumberNodesInConn(const std::map<int,int>& newNodeNumbersO2N)
+{
+ this->renumberNodesInConnT< std::map<int,int> >(newNodeNumbersO2N);
}
/*!
*/
void MEDCoupling1DGTUMesh::renumberNodesInConn(const INTERP_KERNEL::HashMap<int,int>& newNodeNumbersO2N)
{
- getNumberOfCells();//only to check that all is well defined.
- //
- int nbElemsIn(getNumberOfNodes()),nbOfTuples(_conn->getNumberOfTuples());
- int *pt(_conn->getPointer());
- for(int i=0;i<nbOfTuples;i++,pt++)
- {
- if(*pt==-1) continue;
- if(*pt>=0 && *pt<nbElemsIn)
- {
- INTERP_KERNEL::HashMap<int,int>::const_iterator it(newNodeNumbersO2N.find(*pt));
- if(it!=newNodeNumbersO2N.end())
- *pt=(*it).second;
- else
- {
- std::ostringstream oss; oss << "MEDCoupling1DGTUMesh::renumberNodesInConn : At pos #" << i << " of connectivity, node id is " << *pt << ". Not in keys of input map !";
- throw INTERP_KERNEL::Exception(oss.str().c_str());
- }
- }
- else
- {
- std::ostringstream oss; oss << "MEDCoupling1DGTUMesh::renumberNodesInConn : error on tuple #" << i << " value is " << *pt << " and indirectionnal array as a size equal to " << nbElemsIn;
- throw INTERP_KERNEL::Exception(oss.str().c_str());
- }
- }
- //
- updateTime();
+ this->renumberNodesInConnT< INTERP_KERNEL::HashMap<int,int> >(newNodeNumbersO2N);
+}
+
+/*!
+ * Same than renumberNodesInConn(const int *) except that here the format of old-to-new traducer is using map instead
+ * of array. This method is dedicated for renumbering from a big set of nodes the a tiny set of nodes which is the case during extraction
+ * of a big mesh.
+ */
+void MEDCoupling1DGTUMesh::renumberNodesInConn(const std::map<int,int>& newNodeNumbersO2N)
+{
+ this->renumberNodesInConnT< std::map<int,int> >(newNodeNumbersO2N);
}
/*!
MEDCOUPLING_EXPORT DataArrayInt *getNodeIdsInUse(int& nbrOfNodesInUse) const;
MEDCOUPLING_EXPORT void renumberNodesWithOffsetInConn(int offset);
MEDCOUPLING_EXPORT void renumberNodesInConn(const INTERP_KERNEL::HashMap<int,int>& newNodeNumbersO2N);
+ MEDCOUPLING_EXPORT void renumberNodesInConn(const std::map<int,int>& newNodeNumbersO2N) override;
MEDCOUPLING_EXPORT void renumberNodesInConn(const int *newNodeNumbersO2N);
MEDCOUPLING_EXPORT void fillCellIdsToKeepFromNodeIds(const int *begin, const int *end, bool fullyIn, DataArrayInt *&cellIdsKeptArr) const;
MEDCOUPLING_EXPORT int getNumberOfNodesInCell(int cellId) const;
DataArrayInt *simplexizePlanarFace6();
MEDCoupling1DGTUMesh *computeDualMesh3D() const;
MEDCoupling1DGTUMesh *computeDualMesh2D() const;
+ template<class MAPCLS>
+ void renumberNodesInConnT(const MAPCLS& newNodeNumbersO2N);
private:
MCAuto<DataArrayInt> _conn;
public:
MEDCOUPLING_EXPORT DataArrayInt *getNodeIdsInUse(int& nbrOfNodesInUse) const;
MEDCOUPLING_EXPORT void renumberNodesWithOffsetInConn(int offset);
MEDCOUPLING_EXPORT void renumberNodesInConn(const INTERP_KERNEL::HashMap<int,int>& newNodeNumbersO2N);
+ MEDCOUPLING_EXPORT void renumberNodesInConn(const std::map<int,int>& newNodeNumbersO2N) override;
MEDCOUPLING_EXPORT void renumberNodesInConn(const int *newNodeNumbersO2N);
MEDCOUPLING_EXPORT void fillCellIdsToKeepFromNodeIds(const int *begin, const int *end, bool fullyIn, DataArrayInt *&cellIdsKeptArr) const;
MEDCOUPLING_EXPORT int getNumberOfNodesInCell(int cellId) const;
private:
void checkDynamicGeoT2ype() const;
static MEDCoupling1DGTUMesh *Merge1DGTUMeshesLL(std::vector<const MEDCoupling1DGTUMesh *>& a);
+ template<class MAPCLS>
+ void renumberNodesInConnT(const MAPCLS& newNodeNumbersO2N);
private:
MCAuto<DataArrayInt> _conn_indx;
MCAuto<DataArrayInt> _conn;
--- /dev/null
+// Copyright (C) 2018 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, 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
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+// Lesser General Public License for more details.
+//
+// You should have received a copy of the GNU Lesser General Public
+// License along with this library; if not, write to the Free Software
+// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+//
+// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
+//
+// Author : Anthony Geay (EDF R&D)
+
+#pragma once
+#include "MEDCoupling1GTUMesh.hxx"
+
+#include <sstream>
+
+template<class MAPCLS>
+void MEDCoupling::MEDCoupling1SGTUMesh::renumberNodesInConnT(const MAPCLS& newNodeNumbersO2N)
+{
+ getNumberOfCells();//only to check that all is well defined.
+ int *begPtr(_conn->getPointer());
+ int nbElt(_conn->getNumberOfTuples());
+ int *endPtr(begPtr+nbElt);
+ for(int *it=begPtr;it!=endPtr;it++)
+ {
+ auto it2(newNodeNumbersO2N.find(*it));
+ if(it2!=newNodeNumbersO2N.end())
+ {
+ *it=(*it2).second;
+ }
+ else
+ {
+ std::ostringstream oss; oss << "MEDCoupling1SGTUMesh::renumberNodesInConn : At pos #" << std::distance(begPtr,it) << " of nodal connectivity value is " << *it << ". Not in map !";
+ throw INTERP_KERNEL::Exception(oss.str().c_str());
+ }
+ }
+ updateTime();
+}
+
+template<class MAPCLS>
+void MEDCoupling::MEDCoupling1DGTUMesh::renumberNodesInConnT(const MAPCLS& newNodeNumbersO2N)
+{
+ getNumberOfCells();//only to check that all is well defined.
+ //
+ int nbOfTuples(_conn->getNumberOfTuples());
+ int *pt(_conn->getPointer());
+ for(int i=0;i<nbOfTuples;i++,pt++)
+ {
+ if(*pt==-1) continue;
+ if(*pt>=0)
+ {
+ auto it(newNodeNumbersO2N.find(*pt));
+ if(it!=newNodeNumbersO2N.end())
+ *pt=(*it).second;
+ else
+ {
+ std::ostringstream oss; oss << "MEDCoupling1DGTUMesh::renumberNodesInConn : At pos #" << i << " of connectivity, node id is " << *pt << ". Not in keys of input map !";
+ throw INTERP_KERNEL::Exception(oss.str().c_str());
+ }
+ }
+ else
+ {
+ std::ostringstream oss; oss << "MEDCoupling1DGTUMesh::renumberNodesInConn : error on tuple #" << i << " value is " << *pt << " ! Should be >=0 !";
+ throw INTERP_KERNEL::Exception(oss.str().c_str());
+ }
+ }
+ //
+ updateTime();
+}
std::map<T,T> _m;
};
- typedef MapKeyVal<int> MapII;
+ using MapII = MapKeyVal<int>;
}
#endif
MEDCOUPLING_EXPORT virtual void fillCellIdsToKeepFromNodeIds(const int *begin, const int *end, bool fullyIn, DataArrayInt *&cellIdsKeptArr) const = 0;
MEDCOUPLING_EXPORT virtual void renumberNodesInConn(const int *newNodeNumbersO2N) = 0;
MEDCOUPLING_EXPORT virtual void renumberNodesInConn(const INTERP_KERNEL::HashMap<int,int>& newNodeNumbersO2N) = 0;
+ MEDCOUPLING_EXPORT virtual void renumberNodesInConn(const std::map<int,int>& newNodeNumbersO2N) = 0;
MEDCOUPLING_EXPORT virtual void renumberNodesWithOffsetInConn(int offset) = 0;
MEDCOUPLING_EXPORT virtual void renumberNodes(const int *newNodeNumbers, int newNbOfNodes);
MEDCOUPLING_EXPORT virtual void renumberNodesCenter(const int *newNodeNumbers, int newNbOfNodes);
//
// Author : Anthony Geay (EDF R&D)
-#include "MEDCouplingUMesh.hxx"
+#include "MEDCouplingUMesh.txx"
#include "MEDCouplingCMesh.hxx"
#include "MEDCoupling1GTUMesh.hxx"
#include "MEDCouplingFieldDouble.hxx"
*/
void MEDCouplingUMesh::renumberNodesInConn(const INTERP_KERNEL::HashMap<int,int>& newNodeNumbersO2N)
{
- checkConnectivityFullyDefined();
- int *conn(getNodalConnectivity()->getPointer());
- const int *connIndex(getNodalConnectivityIndex()->getConstPointer());
- int nbOfCells(getNumberOfCells());
- for(int i=0;i<nbOfCells;i++)
- for(int iconn=connIndex[i]+1;iconn!=connIndex[i+1];iconn++)
- {
- int& node=conn[iconn];
- if(node>=0)//avoid polyhedron separator
- {
- INTERP_KERNEL::HashMap<int,int>::const_iterator it(newNodeNumbersO2N.find(node));
- if(it!=newNodeNumbersO2N.end())
- {
- node=(*it).second;
- }
- else
- {
- std::ostringstream oss; oss << "MEDCouplingUMesh::renumberNodesInConn(map) : presence in connectivity for cell #" << i << " of node #" << node << " : Not in map !";
- throw INTERP_KERNEL::Exception(oss.str());
- }
- }
- }
- _nodal_connec->declareAsNew();
- updateTime();
+ this->renumberNodesInConnT< INTERP_KERNEL::HashMap<int,int> >(newNodeNumbersO2N);
+}
+
+/*!
+ * Same than renumberNodesInConn(const int *) except that here the format of old-to-new traducer is using map instead
+ * of array. This method is dedicated for renumbering from a big set of nodes the a tiny set of nodes which is the case during extraction
+ * of a big mesh.
+ */
+void MEDCouplingUMesh::renumberNodesInConn(const std::map<int,int>& newNodeNumbersO2N)
+{
+ this->renumberNodesInConnT< std::map<int,int> >(newNodeNumbersO2N);
}
/*!
MEDCOUPLING_EXPORT void renumberNodesWithOffsetInConn(int offset);
MEDCOUPLING_EXPORT void renumberNodesInConn(const INTERP_KERNEL::HashMap<int,int>& newNodeNumbersO2N);
MEDCOUPLING_EXPORT void renumberNodesInConn(const int *newNodeNumbersO2N);
+ MEDCOUPLING_EXPORT void renumberNodesInConn(const std::map<int,int>& newNodeNumbersO2N) override;
MEDCOUPLING_EXPORT void shiftNodeNumbersInConn(int delta);
MEDCOUPLING_EXPORT void duplicateNodesInConn(const int *nodeIdsToDuplicateBg, const int *nodeIdsToDuplicateEnd, int offset);
MEDCOUPLING_EXPORT void renumberCells(const int *old2NewBg, bool check=true);
const std::vector<int>& insidePoints, std::vector<int>& modifiedFace);
void attractSeg3MidPtsAroundNodesUnderground(double ratio, const int *nodeIdsBg, const int *nodeIdsEnd);
DataArrayInt *internalColinearize2D(double eps, bool stayConform);
+ template<class MAPCLS>
+ void renumberNodesInConnT(const MAPCLS& newNodeNumbersO2N);
public:
MEDCOUPLING_EXPORT static DataArrayInt *ComputeRangesFromTypeDistribution(const std::vector<int>& code);
MEDCOUPLING_EXPORT static const int N_MEDMEM_ORDER=25;
--- /dev/null
+// Copyright (C) 2018 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, 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
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+// Lesser General Public License for more details.
+//
+// You should have received a copy of the GNU Lesser General Public
+// License along with this library; if not, write to the Free Software
+// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+//
+// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
+//
+// Author : Anthony Geay (EDF R&D)
+
+#pragma once
+#include "MEDCouplingUMesh.hxx"
+
+#include <sstream>
+
+template<class MAPCLS>
+void MEDCoupling::MEDCouplingUMesh::renumberNodesInConnT(const MAPCLS& newNodeNumbersO2N)
+{
+ checkConnectivityFullyDefined();
+ int *conn(getNodalConnectivity()->getPointer());
+ const int *connIndex(getNodalConnectivityIndex()->getConstPointer());
+ int nbOfCells(getNumberOfCells());
+ for(int i=0;i<nbOfCells;i++)
+ for(int iconn=connIndex[i]+1;iconn!=connIndex[i+1];iconn++)
+ {
+ int& node=conn[iconn];
+ if(node>=0)//avoid polyhedron separator
+ {
+ auto it(newNodeNumbersO2N.find(node));
+ if(it!=newNodeNumbersO2N.end())
+ {
+ node=(*it).second;
+ }
+ else
+ {
+ std::ostringstream oss; oss << "MEDCouplingUMesh::renumberNodesInConn(map) : presence in connectivity for cell #" << i << " of node #" << node << " : Not in map !";
+ throw INTERP_KERNEL::Exception(oss.str());
+ }
+ }
+ }
+ _nodal_connec->declareAsNew();
+ updateTime();
+}
virtual PyObject *findCommonCells(int compType, int startCellId=0) const throw(INTERP_KERNEL::Exception)
{
- DataArrayInt *v0=0,*v1=0;
+ DataArrayInt *v0(nullptr),*v1(nullptr);
self->findCommonCells(compType,startCellId,v0,v1);
PyObject *res = PyList_New(2);
PyList_SetItem(res,0,SWIG_NewPointerObj(SWIG_as_voidptr(v0),SWIGTYPE_p_MEDCoupling__DataArrayInt, SWIG_POINTER_OWN | 0 ));
virtual void renumberNodesInConn(PyObject *li) throw(INTERP_KERNEL::Exception)
{
- void *da=0;
- int res1=SWIG_ConvertPtr(li,&da,SWIGTYPE_p_MEDCoupling__DataArrayInt, 0 | 0 );
+ void *da(nullptr);
+ {
+ int res1(SWIG_ConvertPtr(li,&da,SWIGTYPE_p_MEDCoupling__MapII, 0 | 0 ));
+ if(SWIG_IsOK(res1))
+ {
+ MapII *da2(reinterpret_cast<MapII *>(da));
+ self->renumberNodesInConn(da2->data());
+ return ;
+ }
+ }
+ int res1(SWIG_ConvertPtr(li,&da,SWIGTYPE_p_MEDCoupling__DataArrayInt, 0 | 0 ));
if (!SWIG_IsOK(res1))
{
int size;
}
else
{
- DataArrayInt *da2=reinterpret_cast< DataArrayInt * >(da);
+ DataArrayInt *da2(reinterpret_cast< DataArrayInt * >(da));
if(!da2)
throw INTERP_KERNEL::Exception("Not null DataArrayInt instance expected !");
da2->checkAllocated();
virtual DataArrayInt *fillCellIdsToKeepFromNodeIds(PyObject *li, bool fullyIn) const
{
- DataArrayInt *ret=0;
+ DataArrayInt *ret(nullptr);
//
int szArr,sw,iTypppArr;
std::vector<int> stdvecTyyppArr;