1 // Copyright (C) 2007-2020 CEA/DEN, EDF R&D
3 // This library is free software; you can redistribute it and/or
4 // modify it under the terms of the GNU Lesser General Public
5 // License as published by the Free Software Foundation; either
6 // version 2.1 of the License, or (at your option) any later version.
8 // This library is distributed in the hope that it will be useful,
9 // but WITHOUT ANY WARRANTY; without even the implied warranty of
10 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
11 // Lesser General Public License for more details.
13 // You should have received a copy of the GNU Lesser General Public
14 // License along with this library; if not, write to the Free Software
15 // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
17 // See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
20 #ifndef __PARAMEDMEM_MEDCOUPLINGSKYLINEARRAY_HXX__
21 #define __PARAMEDMEM_MEDCOUPLINGSKYLINEARRAY_HXX__
23 #include "MEDCoupling.hxx"
24 #include "MEDCouplingMemArray.hxx"
26 #include "NormalizedGeometricTypes"
33 * Class allowing the easy manipulation of the indexed array format, where the first array (the "indices") is a set of offsets to
34 * be used in the second array (the "values"), to extract packs of values.
38 * values = [1,24,2,33,6,7,10,11,9,28]
39 * which describes 3 packs of (integer) values : [1,24] and [2,33,6,7,10] and [11,9,28]
41 * Thus the index array is always monotic ascendant.
43 * This class allows to pursue this logic up to 3 levels, i.e. the first array (the "indices") points to packs in the
44 * second (the "values"), which itself points to identifiers in a third array (the "sub-values").
46 * This particularly useful for connectivity of pure polygonal/polyhedral meshes.
49 * super-index = [0,1,3]
51 * values = [28,1,4,2,35,8,9,10,1,12]
52 * 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].
53 * The second super-pack is [[2,35,8], [9,10,1,12]] and has two packs [2,35,8] and [9,10,1,12].
54 * Note that contrary to index, the integers in super-index are interpreted as being inclusive: the first super-pack
55 * goes from offset 0 to offset 1, inclusive. This is not the same for index, where the upper bound is exclusive.
57 class MEDCOUPLING_EXPORT MEDCouplingSkyLineArray : public RefCountObject
60 static MEDCouplingSkyLineArray * New();
61 static MEDCouplingSkyLineArray * New( const std::vector<mcIdType>& index, const std::vector<mcIdType>& value);
62 static MEDCouplingSkyLineArray * New( DataArrayIdType* index, DataArrayIdType* value );
63 static MEDCouplingSkyLineArray * New( const MEDCouplingSkyLineArray & other );
65 static MEDCouplingSkyLineArray * BuildFromPolyhedronConn( const DataArrayIdType* c, const DataArrayIdType* cI );
66 std::string getClassName() const override { return std::string("MEDCouplingSkyLineArray"); }
67 std::size_t getHeapMemorySizeWithoutChildren() const;
68 std::vector<const BigMemoryObject *> getDirectChildrenWithNull() const;
70 void set( DataArrayIdType* index, DataArrayIdType* value );
71 void set3( DataArrayIdType* superIndex, DataArrayIdType* index, DataArrayIdType* value );
73 mcIdType getSuperNumberOf() const { return ToIdType(_super_index->getNbOfElems())-1; }
74 mcIdType getNumberOf() const { return ToIdType(_index->getNbOfElems())-1; }
75 mcIdType getLength() const { return ToIdType(_values->getNbOfElems()); }
77 const mcIdType* getSuperIndex() const { return _super_index->begin(); }
78 const mcIdType* getIndex() const { return _index->begin(); }
79 const mcIdType* getValues() const { return _values->begin(); }
81 DataArrayIdType* getSuperIndexArray() const;
82 DataArrayIdType* getIndexArray() const;
83 DataArrayIdType* getValuesArray() const;
85 std::string simpleRepr() const;
87 void getSimplePackSafe(const mcIdType absolutePackId, std::vector<mcIdType> & pack) const;
88 const mcIdType * getSimplePackSafePtr(const mcIdType absolutePackId, mcIdType & packSize) const;
89 void findPackIds(const std::vector<mcIdType> & superPackIndices, const mcIdType *packBg, const mcIdType *packEnd,
90 std::vector<mcIdType>& out) const;
92 void deletePack(const mcIdType superIdx, const mcIdType idx);
93 void deleteSimplePack(const mcIdType idx);
94 void pushBackPack(const mcIdType superIdx, const mcIdType * packBg, const mcIdType * packEnd);
96 void replaceSimplePack(const mcIdType idx, const mcIdType * packBg, const mcIdType * packEnd);
97 void replacePack(const mcIdType superIdx, const mcIdType idx, const mcIdType * packBg, const mcIdType * packEnd);
99 void deleteSimplePacks(const DataArrayIdType* idx);
100 void replaceSimplePacks(const DataArrayIdType* idx, const std::vector<const DataArrayIdType*>& packs);
102 void convertToPolyhedronConn( MCAuto<DataArrayIdType>& c, MCAuto<DataArrayIdType>& cI) const;
105 MEDCouplingSkyLineArray();
106 ~MEDCouplingSkyLineArray();
108 void checkSuperIndex(const std::string& func) const;
109 void validSuperIndex(const std::string& func, mcIdType superIndex) const;
110 void validIndex(const std::string& func, mcIdType index) const;
111 void validSuperIndexAndIndex(const std::string& func, mcIdType superIndex, mcIdType index) const;
113 MCAuto<DataArrayIdType> _super_index;
114 MCAuto<DataArrayIdType> _index;
115 MCAuto<DataArrayIdType> _values;