Salome HOME
typo-fix by Kunda
[tools/medcoupling.git] / src / MEDCoupling / MEDCouplingSkyLineArray.hxx
index 8c3a2f125eb3be8d7e2d937c14058ba1a03ac7e5..7c7d04a03a4a482299fdc01f938b5e3283289b4a 100644 (file)
 namespace MEDCoupling
 {
   /**!
-   * Class allowing the easy manipulation of the indexed array format, where the first array is a set of offsets to
-   * be used in the second array, to extract packs of values.
+   * Class allowing the easy manipulation of the indexed array format, where the first array (the "indices") is a set of offsets to
+   * be used in the second array (the "values"), to extract packs of values.
    *
-   * This class allows to pursuie this logic up to 3 levels, i.e. the first array points to packs in the second, which
-   * itself points to identifiers in the third array.
+   * Example:
+   *    index = [0,2,7,10]
+   *    values = [1,24,2,33,6,7,10,11,9,28]
+   * which describes 3 packs of (integer) values : [1,24] and [2,33,6,7,10] and [11,9,28]
+   *
+   * Thus the index array is always monotic ascendant.
+   *
+   * This class allows to pursue this logic up to 3 levels, i.e. the first array (the "indices") points to packs in the
+   * second (the "values"), which itself points to identifiers in a third array (the "sub-values").
    *
    * This particularly useful for connectivity of pure polygonal/polyhedral meshes.
+   *
+   * Example:
+   *     super-index = [0,1,3]
+   *     index = [0,3,6,10]
+   *     values = [28,1,4,2,35,8,9,10,1,12]
+   * which represent two 3 packs and two super-packs. The first super-pack is [[28,1,4]] and has only one pack [28,1,4].
+   * The second super-pack is [[2,35,8], [9,10,1,12]] and has two packs [2,35,8] and [9,10,1,12].
+   * Note that contrary to index, the integers in super-index are interpreted as being inclusive: the first super-pack
+   * goes from offset 0 to offset 1, inclusive. This is not the same for index, where the upper bound is exclusive.
    */
   class MEDCOUPLING_EXPORT MEDCouplingSkyLineArray : public RefCountObject
   {
@@ -44,31 +60,60 @@ namespace MEDCoupling
     static MEDCouplingSkyLineArray * New();
     static MEDCouplingSkyLineArray * New( const std::vector<int>& index, const std::vector<int>& value);
     static MEDCouplingSkyLineArray * New( DataArrayInt* index, DataArrayInt* value );
+    static MEDCouplingSkyLineArray * New( const MEDCouplingSkyLineArray & other );
+
+    static MEDCouplingSkyLineArray * BuildFromPolyhedronConn( const DataArrayInt* c, const DataArrayInt* cI );
 
     std::size_t getHeapMemorySizeWithoutChildren() const;
     std::vector<const BigMemoryObject *> getDirectChildrenWithNull() const;
 
     void set( DataArrayInt* index, DataArrayInt* value );
+    void set3( DataArrayInt* superIndex, DataArrayInt* index, DataArrayInt* value );
 
+    int getSuperNumberOf()   const { return _super_index->getNbOfElems()-1; }
     int getNumberOf() const { return _index->getNbOfElems()-1; }
     int getLength()   const { return _values->getNbOfElems(); }
+
+    const int* getSuperIndex() const { return _super_index->begin(); }
     const int* getIndex() const { return _index->begin(); }
     const int* getValues() const { return _values->begin(); }
 
+    DataArrayInt* getSuperIndexArray() const;
     DataArrayInt* getIndexArray() const;
     DataArrayInt* getValuesArray() const;
 
     std::string simpleRepr() const;
 
-//    replaceWithPackFromOther()
+    void getSimplePackSafe(const int absolutePackId, std::vector<int> & pack) const;
+    const int * getSimplePackSafePtr(const int absolutePackId, int & packSize) const;
+    void findPackIds(const std::vector<int> & superPackIndices, const int *packBg, const int *packEnd,
+                     std::vector<int>& out) const;
+
+    void deletePack(const int superIdx, const int idx);
+    void deleteSimplePack(const int idx);
+    void pushBackPack(const int superIdx, const int * packBg, const int * packEnd);
+
+    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 deleteSimplePacks(const DataArrayInt* idx);
+    void replaceSimplePacks(const DataArrayInt* idx, const std::vector<const DataArrayInt*>& packs);
+    
+    void convertToPolyhedronConn( MCAuto<DataArrayInt>& c,  MCAuto<DataArrayInt>& 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;
+
+    MCAuto<DataArrayInt> _super_index;
     MCAuto<DataArrayInt> _index;
     MCAuto<DataArrayInt> _values;
-    MCAuto<DataArrayInt> _sub_values;
   };
+
 }
 # endif