Salome HOME
Bug with FindClosestTupleIdAlg fixed (preventing the threshold to be null)
[tools/medcoupling.git] / src / MEDCoupling / MEDCouplingSkyLineArray.hxx
index 356e28a8ef967c9da64443c7a0266834fb3d7962..e2dca0b59fa93520b08d6c345e98642571c59110 100644 (file)
@@ -1,4 +1,4 @@
-// Copyright (C) 2007-2019  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 <vector>
+#include <functional>
 
 namespace MEDCoupling
 {
@@ -63,6 +63,28 @@ namespace MEDCoupling
     static MEDCouplingSkyLineArray * New( const MEDCouplingSkyLineArray & other );
 
     static MEDCouplingSkyLineArray * BuildFromPolyhedronConn( const DataArrayIdType* c, const DataArrayIdType* cI );
+
+    static std::vector< MCAuto<DataArrayIdType> > RetrieveVecIndex(const std::vector< MCAuto<MEDCouplingSkyLineArray> >& vecSka)
+    {
+       auto fct = [](MEDCouplingSkyLineArray *ska) { return ska->getIndexArray(); };
+       return RetrieveVecOfSkyLineArrayGen(vecSka,fct);
+    }
+    
+    static std::vector< MCAuto<DataArrayIdType> > RetrieveVecValues(const std::vector< MCAuto<MEDCouplingSkyLineArray> >& vecSka)
+    {
+       auto fct = [](MEDCouplingSkyLineArray *ska) { return ska->getValuesArray(); };
+       return RetrieveVecOfSkyLineArrayGen(vecSka,fct);
+    }
+    
+    static std::vector< MCAuto<DataArrayIdType> > RetrieveVecOfSkyLineArrayGen(const std::vector< MCAuto<MEDCouplingSkyLineArray> >& vecSka, std::function<DataArrayIdType *(MEDCouplingSkyLineArray *)> fct)
+    {
+       std::size_t sz(vecSka.size());
+       std::vector< MCAuto<DataArrayIdType> > ret(sz);
+       std::vector< MCAuto<DataArrayIdType> >::iterator it(ret.begin());
+       std::for_each(vecSka.begin(),vecSka.end(),[&it,fct](MCAuto<MEDCouplingSkyLineArray> elt) { *it++ = MCAuto<DataArrayIdType>::TakeRef(fct(elt)); } );
+       return ret;
+    }
+
     std::string getClassName() const override { return std::string("MEDCouplingSkyLineArray"); }
     std::size_t getHeapMemorySizeWithoutChildren() const;
     std::vector<const BigMemoryObject *> getDirectChildrenWithNull() const;
@@ -82,8 +104,16 @@ namespace MEDCoupling
     DataArrayIdType* getIndexArray() const;
     DataArrayIdType* getValuesArray() const;
 
+    MEDCouplingSkyLineArray *deepCopy() const;
+
     std::string simpleRepr() const;
 
+    void thresholdPerPack(mcIdType threshold, MCAuto<MEDCouplingSkyLineArray>& left, MCAuto<MEDCouplingSkyLineArray>& right) const;
+
+    MEDCouplingSkyLineArray *groupPacks(const DataArrayIdType *indexedPacks) const;
+    MEDCouplingSkyLineArray *uniqueNotSortedByPack() const;
+    static MEDCouplingSkyLineArray *AggregatePacks(const std::vector<const MEDCouplingSkyLineArray *>& sks);
+
     void getSimplePackSafe(const mcIdType absolutePackId, std::vector<mcIdType> & pack) const;
     const mcIdType * getSimplePackSafePtr(const mcIdType absolutePackId, mcIdType & packSize) const;
     void findPackIds(const std::vector<mcIdType> & superPackIndices, const mcIdType *packBg, const mcIdType *packEnd,
@@ -115,5 +145,24 @@ namespace MEDCoupling
     MCAuto<DataArrayIdType> _values;
   };
 
+  template<typename T>
+  class SkyLineArrayGenIterator : public std::iterator< std::input_iterator_tag, const mcIdType *, mcIdType, const mcIdType **, const mcIdType *>
+  {
+    std::size_t _num = 0;
+    std::vector<const MEDCouplingSkyLineArray *> *_data = nullptr;
+  public:
+    explicit SkyLineArrayGenIterator(std::size_t num , std::vector<const MEDCouplingSkyLineArray *> *data) : _num(num),_data(data) {}
+    SkyLineArrayGenIterator<T>& 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<SkyLineArrayIndexPtrFunctor>;
+  
+  struct SkyLineArrayValuesPtrFunctor { const mcIdType *operator()(const MEDCouplingSkyLineArray *ska) { return ska->getValues(); } };
+
+  using SkyLineArrayValuesIterator = SkyLineArrayGenIterator<SkyLineArrayValuesPtrFunctor>;
 }
-# endif