X-Git-Url: http://git.salome-platform.org/gitweb/?a=blobdiff_plain;f=src%2FMEDPartitioner%2FMEDPARTITIONER_Utils.cxx;h=52db6e97ed7a43fb4124ec0844d6bc99d7a2ce57;hb=8411b13fec372c7635bf04d2bb81a869dc038fdd;hp=ef0d248b7e377987e8d4bfeaf9ff88e028653652;hpb=79386ac5c73f8365c428b8ef595c4ef004959667;p=tools%2Fmedcoupling.git diff --git a/src/MEDPartitioner/MEDPARTITIONER_Utils.cxx b/src/MEDPartitioner/MEDPARTITIONER_Utils.cxx index ef0d248b7..52db6e97e 100644 --- a/src/MEDPartitioner/MEDPARTITIONER_Utils.cxx +++ b/src/MEDPartitioner/MEDPARTITIONER_Utils.cxx @@ -1,4 +1,4 @@ -// Copyright (C) 2007-2016 CEA/DEN, EDF R&D +// Copyright (C) 2007-2020 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 @@ -44,7 +44,7 @@ int MEDPARTITIONER::MyGlobals::_Rank=-1; int MEDPARTITIONER::MyGlobals::_World_Size=-1; int MEDPARTITIONER::MyGlobals::_Randomize=0; int MEDPARTITIONER::MyGlobals::_Atomize=0; -int MEDPARTITIONER::MyGlobals::_Creates_Boundary_Faces=0; +int MEDPARTITIONER::MyGlobals::_Create_Boundary_Faces=0; int MEDPARTITIONER::MyGlobals::_Create_Joints=0; std::vector MEDPARTITIONER::MyGlobals::_File_Names; std::vector MEDPARTITIONER::MyGlobals::_Mesh_Names; @@ -131,16 +131,16 @@ void MEDPARTITIONER::RandomizeAdj(int* xadj, int* adjncy, std::vector& ran, std::cerr << "MEDPARTITIONER::RandomizeAdj only works on one proc!" << std::endl; return; } - int size=ran.size(); + std::size_t size=ran.size(); std::vector invran(size); - for (int i=0; i& v return oss.str(); } -std::string MEDPARTITIONER::ReprMapOfStringInt(const std::map& mymap) +std::string MEDPARTITIONER::ReprMapOfStringInt(const std::map& mymap) { if (mymap.size()==0) return std::string(" NONE\n"); std::ostringstream oss; - for (std::map::const_iterator i=mymap.begin(); i!=mymap.end(); ++i) + for (std::map::const_iterator i=mymap.begin(); i!=mymap.end(); ++i) oss << " -> [" << (*i).first << "]=" << (*i).second << std::endl; return oss.str(); } @@ -285,10 +285,10 @@ std::string MEDPARTITIONER::EraseTagSerialized(const std::string& fromStr, const * elements first and second of map give one elements in result vector of string * converting formatted the int second as firsts characters ending at first slash */ -std::vector MEDPARTITIONER::VectorizeFromMapOfStringInt(const std::map& mymap) +std::vector MEDPARTITIONER::VectorizeFromMapOfStringInt(const std::map& mymap) { std::vector res; - for (std::map::const_iterator i=mymap.begin(); i!=mymap.end(); ++i) + for (std::map::const_iterator i=mymap.begin(); i!=mymap.end(); ++i) { std::ostringstream oss; oss << (*i).second << "/" << (*i).first; @@ -300,9 +300,9 @@ std::vector MEDPARTITIONER::VectorizeFromMapOfStringInt(const std:: /* * if existing identicals (first,second) in vector no problem, else Exception */ -std::map MEDPARTITIONER::DevectorizeToMapOfStringInt(const std::vector& vec) +std::map MEDPARTITIONER::DevectorizeToMapOfStringInt(const std::vector& vec) { - std::map res; + std::map res; for (std::vector::const_iterator i=vec.begin(); i!=vec.end(); ++i) { std::size_t pos=0; @@ -310,11 +310,11 @@ std::map MEDPARTITIONER::DevectorizeToMapOfStringInt(const std: std::size_t found=(*i).find('/'); //first slash if ((found==std::string::npos) || (found<1)) throw INTERP_KERNEL::Exception("Error aIntNumber/anyString is expected"); - int second; + mcIdType second; std::istringstream iss((*i).substr(pos,found)); iss >> second; std::string first=(*i).substr(pos+found+1,posmax-found); - std::map::iterator it=res.find(first); + std::map::iterator it=res.find(first); if (it!=res.end()) if ((*it).second!=second) throw INTERP_KERNEL::Exception("Error not the same map value"); @@ -364,7 +364,7 @@ std::map< std::string,std::vector > MEDPARTITIONER::DevectorizeToMa iss >> sizeVector; std::string keymap=enTete.substr(foundKey+7,foundSizeVector-foundKey-7); for (int ii=1; ii<=sizeVector; ii++) - res[keymap].push_back(vs[ii]); //add unconditionnaly,so merge duplicates in second vector + res[keymap].push_back(vs[ii]); //add unconditionally,so merge duplicates in second vector } return res; } @@ -506,17 +506,17 @@ void MEDPARTITIONER::FieldShortDescriptionToData(const std::string& description, IT=StrToInt(ExtractFromDescription(description,"IT=")); } -MEDCoupling::DataArrayInt *MEDPARTITIONER::CreateDataArrayIntFromVector(const std::vector& v) +MEDCoupling::DataArrayIdType *MEDPARTITIONER::CreateDataArrayIntFromVector(const std::vector& v) { - MEDCoupling::DataArrayInt* p=MEDCoupling::DataArrayInt::New(); + MEDCoupling::DataArrayIdType* p=MEDCoupling::DataArrayIdType::New(); p->alloc(v.size(),1); std::copy(v.begin(),v.end(),p->getPointer()); return p; } -MEDCoupling::DataArrayInt *MEDPARTITIONER::CreateDataArrayIntFromVector(const std::vector& v,const int nbComponents) +MEDCoupling::DataArrayIdType *MEDPARTITIONER::CreateDataArrayIntFromVector(const std::vector& v,const int nbComponents) { - MEDCoupling::DataArrayInt* p=MEDCoupling::DataArrayInt::New(); + MEDCoupling::DataArrayIdType* p=MEDCoupling::DataArrayIdType::New(); if (v.size()%nbComponents!=0) throw INTERP_KERNEL::Exception("Problem size modulo nbComponents != 0"); p->alloc(v.size()/nbComponents,nbComponents); @@ -539,9 +539,9 @@ std::vector MEDPARTITIONER::BrowseFieldDouble(const MEDCoupling::ME std::vector res; if (fd->getArray()) { - int nb=fd->getArray()->getNumberOfComponents(); - res.push_back("nbComponents="); res.back()+=IntToStr(nb); - for (int i=0; igetArray()->getNumberOfComponents(); + res.push_back("nbComponents="); res.back()+=IntToStr((int)nb); + for (unsigned int i=0; igetArray()->getInfoOnComponent(i); @@ -704,7 +704,7 @@ std::vector MEDPARTITIONER::GetInfosOfField(const char *fileName, c { for (int j=0; j MEDPARTITIONER::GetInfosOfField(const char *fileName, c return res; } +MEDCoupling::MCAuto< MEDCoupling::DataArrayInt32 > MEDPARTITIONER::FromIdTypeVec( const std::vector< mcIdType >& vec ) +{ + MEDCoupling::DataArrayInt32* array = MEDCoupling::DataArrayInt32::New(); + array->alloc( vec.size(), 1 ); + std::copy( vec.begin(), vec.end(), array->getPointer() ); + return array; +} + + /*! * quick almost human readable information on all fields on a mesh in a .med file */ @@ -830,27 +839,27 @@ MEDCoupling::MEDCouplingUMesh* MEDPARTITIONER::CreateEmptyMEDCouplingUMesh() namespace MEDPARTITIONER { - BBTreeOfDim::BBTreeOfDim( int dim, + BBTreeOfDim::BBTreeOfDim( std::size_t dim, const double* bbs, - int* elems, + mcIdType* elems, int level, - int nbelems, + mcIdType nbelems, double epsilon) { switch ( dim ) { case 3: - _tree=new BBTree<3> (bbs,elems,level,nbelems,epsilon); + _tree=new BBTree<3,mcIdType> (bbs,elems,level,nbelems,epsilon); _PgetElementsAroundPoint = & BBTreeOfDim::_getElementsAroundPoint< 3 >; _PgetIntersectingElems = & BBTreeOfDim::_getIntersectingElems< 3 >; break; case 2: - _tree=new BBTree<2> (bbs,elems,level,nbelems,epsilon); + _tree=new BBTree<2,mcIdType> (bbs,elems,level,nbelems,epsilon); _PgetElementsAroundPoint = & BBTreeOfDim::_getElementsAroundPoint< 2 >; _PgetIntersectingElems = & BBTreeOfDim::_getIntersectingElems< 2 >; break; case 1: - _tree=new BBTree<1> (bbs,elems,level,nbelems,epsilon); + _tree=new BBTree<1,mcIdType> (bbs,elems,level,nbelems,epsilon); _PgetElementsAroundPoint = & BBTreeOfDim::_getElementsAroundPoint< 1 >; _PgetIntersectingElems = & BBTreeOfDim::_getIntersectingElems< 1 >; break; @@ -866,13 +875,13 @@ namespace MEDPARTITIONER } void BBTreeOfDim::getElementsAroundPoint( const double* coordsPtr, - std::vector& elems ) const + std::vector& elems ) const { BBTreeOfDim* me = (BBTreeOfDim*) this; (me->*_PgetElementsAroundPoint) ( coordsPtr, elems ); } void BBTreeOfDim::getIntersectingElems(const double* bb, - std::vector& elems) const + std::vector& elems) const { BBTreeOfDim* me = (BBTreeOfDim*) this; (me->*_PgetIntersectingElems) ( bb, elems );