1 // Copyright (C) 2007-2016 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<int>& index, const std::vector<int>& value);
62 static MEDCouplingSkyLineArray * New( DataArrayInt* index, DataArrayInt* value );
63 static MEDCouplingSkyLineArray * New( const MEDCouplingSkyLineArray & other );
65 static MEDCouplingSkyLineArray * BuildFromPolyhedronConn( const DataArrayInt* c, const DataArrayInt* cI );
67 std::size_t getHeapMemorySizeWithoutChildren() const;
68 std::vector<const BigMemoryObject *> getDirectChildrenWithNull() const;
70 void set( DataArrayInt* index, DataArrayInt* value );
71 void set3( DataArrayInt* superIndex, DataArrayInt* index, DataArrayInt* value );
73 int getSuperNumberOf() const { return _super_index->getNbOfElems()-1; }
74 int getNumberOf() const { return _index->getNbOfElems()-1; }
75 int getLength() const { return _values->getNbOfElems(); }
77 const int* getSuperIndex() const { return _super_index->begin(); }
78 const int* getIndex() const { return _index->begin(); }
79 const int* getValues() const { return _values->begin(); }
81 DataArrayInt* getSuperIndexArray() const;
82 DataArrayInt* getIndexArray() const;
83 DataArrayInt* getValuesArray() const;
85 std::string simpleRepr() const;
87 void getSimplePackSafe(const int absolutePackId, std::vector<int> & pack) const;
88 const int * getSimplePackSafePtr(const int absolutePackId, int & packSize) const;
89 void findPackIds(const std::vector<int> & superPackIndices, const int *packBg, const int *packEnd,
90 std::vector<int>& out) const;
92 void deletePack(const int superIdx, const int idx);
93 void pushBackPack(const int superIdx, const int * packBg, const int * packEnd);
95 void replaceSimplePack(const int idx, const int * packBg, const int * packEnd);
96 void replacePack(const int superIdx, const int idx, const int * packBg, const int * packEnd);
98 void convertToPolyhedronConn( MCAuto<DataArrayInt>& c, MCAuto<DataArrayInt>& cI) const;
101 MEDCouplingSkyLineArray();
102 ~MEDCouplingSkyLineArray();
104 void checkSuperIndex(const std::string& func) const;
105 void validSuperIndex(const std::string& func, int superIndex) const;
106 void validIndex(const std::string& func, int index) const;
107 void validSuperIndexAndIndex(const std::string& func, int superIndex, int index) const;
109 MCAuto<DataArrayInt> _super_index;
110 MCAuto<DataArrayInt> _index;
111 MCAuto<DataArrayInt> _values;