X-Git-Url: http://git.salome-platform.org/gitweb/?a=blobdiff_plain;f=src%2FMEDCoupling%2FMEDCouplingSkyLineArray.hxx;h=e2dca0b59fa93520b08d6c345e98642571c59110;hb=04f1c450d57b28c7c473bdc59dc87eeef7393ca5;hp=bf5d74cabd8bf1bc7a5b4a50d588c2d7eb8f0f0b;hpb=3654e1300eb1df6f81e25049fb90153f451cdaf3;p=tools%2Fmedcoupling.git diff --git a/src/MEDCoupling/MEDCouplingSkyLineArray.hxx b/src/MEDCoupling/MEDCouplingSkyLineArray.hxx index bf5d74cab..e2dca0b59 100644 --- a/src/MEDCoupling/MEDCouplingSkyLineArray.hxx +++ b/src/MEDCoupling/MEDCouplingSkyLineArray.hxx @@ -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 @@ -17,8 +17,7 @@ // See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com // -#ifndef __PARAMEDMEM_MEDCOUPLINGSKYLINEARRAY_HXX__ -#define __PARAMEDMEM_MEDCOUPLINGSKYLINEARRAY_HXX__ +#pragma once #include "MEDCoupling.hxx" #include "MEDCouplingMemArray.hxx" @@ -26,6 +25,7 @@ #include "NormalizedGeometricTypes" #include +#include namespace MEDCoupling { @@ -58,58 +58,111 @@ namespace MEDCoupling { public: static MEDCouplingSkyLineArray * New(); - static MEDCouplingSkyLineArray * New( const std::vector& index, const std::vector& value); - static MEDCouplingSkyLineArray * New( DataArrayInt* index, DataArrayInt* value ); + static MEDCouplingSkyLineArray * New( const std::vector& index, const std::vector& value); + static MEDCouplingSkyLineArray * New( DataArrayIdType* index, DataArrayIdType* value ); static MEDCouplingSkyLineArray * New( const MEDCouplingSkyLineArray & other ); - static MEDCouplingSkyLineArray * BuildFromPolyhedronConn( const DataArrayInt* c, const DataArrayInt* cI ); - + static MEDCouplingSkyLineArray * BuildFromPolyhedronConn( const DataArrayIdType* c, const DataArrayIdType* cI ); + + static std::vector< MCAuto > RetrieveVecIndex(const std::vector< MCAuto >& vecSka) + { + auto fct = [](MEDCouplingSkyLineArray *ska) { return ska->getIndexArray(); }; + return RetrieveVecOfSkyLineArrayGen(vecSka,fct); + } + + static std::vector< MCAuto > RetrieveVecValues(const std::vector< MCAuto >& vecSka) + { + auto fct = [](MEDCouplingSkyLineArray *ska) { return ska->getValuesArray(); }; + return RetrieveVecOfSkyLineArrayGen(vecSka,fct); + } + + static std::vector< MCAuto > RetrieveVecOfSkyLineArrayGen(const std::vector< MCAuto >& vecSka, std::function fct) + { + std::size_t sz(vecSka.size()); + std::vector< MCAuto > ret(sz); + std::vector< MCAuto >::iterator it(ret.begin()); + std::for_each(vecSka.begin(),vecSka.end(),[&it,fct](MCAuto elt) { *it++ = MCAuto::TakeRef(fct(elt)); } ); + return ret; + } + + std::string getClassName() const override { return std::string("MEDCouplingSkyLineArray"); } std::size_t getHeapMemorySizeWithoutChildren() const; std::vector getDirectChildrenWithNull() const; - void set( DataArrayInt* index, DataArrayInt* value ); - void set3( DataArrayInt* superIndex, DataArrayInt* index, DataArrayInt* value ); + void set( DataArrayIdType* index, DataArrayIdType* value ); + void set3( DataArrayIdType* superIndex, DataArrayIdType* index, DataArrayIdType* value ); + + mcIdType getSuperNumberOf() const { return ToIdType(_super_index->getNbOfElems())-1; } + mcIdType getNumberOf() const { return ToIdType(_index->getNbOfElems())-1; } + mcIdType getLength() const { return ToIdType(_values->getNbOfElems()); } - int getSuperNumberOf() const { return _super_index->getNbOfElems()-1; } - int getNumberOf() const { return _index->getNbOfElems()-1; } - int getLength() const { return _values->getNbOfElems(); } + const mcIdType* getSuperIndex() const { return _super_index->begin(); } + const mcIdType* getIndex() const { return _index->begin(); } + const mcIdType* getValues() const { return _values->begin(); } - const int* getSuperIndex() const { return _super_index->begin(); } - const int* getIndex() const { return _index->begin(); } - const int* getValues() const { return _values->begin(); } + DataArrayIdType* getSuperIndexArray() const; + DataArrayIdType* getIndexArray() const; + DataArrayIdType* getValuesArray() const; - DataArrayInt* getSuperIndexArray() const; - DataArrayInt* getIndexArray() const; - DataArrayInt* getValuesArray() const; + MEDCouplingSkyLineArray *deepCopy() const; std::string simpleRepr() const; - void getSimplePackSafe(const int absolutePackId, std::vector & pack) const; - const int * getSimplePackSafePtr(const int absolutePackId, int & packSize) const; - void findPackIds(const std::vector & superPackIndices, const int *packBg, const int *packEnd, - std::vector& out) const; + void thresholdPerPack(mcIdType threshold, MCAuto& left, MCAuto& right) const; + + MEDCouplingSkyLineArray *groupPacks(const DataArrayIdType *indexedPacks) const; + MEDCouplingSkyLineArray *uniqueNotSortedByPack() const; + static MEDCouplingSkyLineArray *AggregatePacks(const std::vector& sks); - void deletePack(const int superIdx, const int idx); - void pushBackPack(const int superIdx, const int * packBg, const int * packEnd); + void getSimplePackSafe(const mcIdType absolutePackId, std::vector & pack) const; + const mcIdType * getSimplePackSafePtr(const mcIdType absolutePackId, mcIdType & packSize) const; + void findPackIds(const std::vector & superPackIndices, const mcIdType *packBg, const mcIdType *packEnd, + std::vector& out) const; - void replaceSimplePack(const int idx, const int * packBg, const int * packEnd); - void replacePack(const int superIdx, const int idx, const int * packBg, const int * packEnd); + void deletePack(const mcIdType superIdx, const mcIdType idx); + void deleteSimplePack(const mcIdType idx); + void pushBackPack(const mcIdType superIdx, const mcIdType * packBg, const mcIdType * packEnd); - void convertToPolyhedronConn( MCAuto& c, MCAuto& cI) const; + void replaceSimplePack(const mcIdType idx, const mcIdType * packBg, const mcIdType * packEnd); + void replacePack(const mcIdType superIdx, const mcIdType idx, const mcIdType * packBg, const mcIdType * packEnd); + + void deleteSimplePacks(const DataArrayIdType* idx); + void replaceSimplePacks(const DataArrayIdType* idx, const std::vector& packs); + + void convertToPolyhedronConn( MCAuto& c, MCAuto& cI) const; private: MEDCouplingSkyLineArray(); ~MEDCouplingSkyLineArray(); void checkSuperIndex(const std::string& func) const; - void validSuperIndex(const std::string& func, int superIndex) const; - void validIndex(const std::string& func, int index) const; - void validSuperIndexAndIndex(const std::string& func, int superIndex, int index) const; + void validSuperIndex(const std::string& func, mcIdType superIndex) const; + void validIndex(const std::string& func, mcIdType index) const; + void validSuperIndexAndIndex(const std::string& func, mcIdType superIndex, mcIdType index) const; + + MCAuto _super_index; + MCAuto _index; + MCAuto _values; + }; - MCAuto _super_index; - MCAuto _index; - MCAuto _values; + template + class SkyLineArrayGenIterator : public std::iterator< std::input_iterator_tag, const mcIdType *, mcIdType, const mcIdType **, const mcIdType *> + { + std::size_t _num = 0; + std::vector *_data = nullptr; + public: + explicit SkyLineArrayGenIterator(std::size_t num , std::vector *data) : _num(num),_data(data) {} + SkyLineArrayGenIterator& operator++() { ++_num; return *this; } + bool operator==(const SkyLineArrayGenIterator& other) const { return _num == other._num; } + bool operator!=(const SkyLineArrayGenIterator& other) const { return !(*this == other); } + reference operator*() const { T tt; return tt((*_data)[_num]); } }; + struct SkyLineArrayIndexPtrFunctor { const mcIdType *operator()(const MEDCouplingSkyLineArray *ska) { return ska->getIndex(); } }; + + using SkyLineArrayIndexIterator = SkyLineArrayGenIterator; + + struct SkyLineArrayValuesPtrFunctor { const mcIdType *operator()(const MEDCouplingSkyLineArray *ska) { return ska->getValues(); } }; + + using SkyLineArrayValuesIterator = SkyLineArrayGenIterator; } -# endif