X-Git-Url: http://git.salome-platform.org/gitweb/?a=blobdiff_plain;f=src%2FMEDCoupling%2FMEDCouplingSkyLineArray.hxx;h=7c7d04a03a4a482299fdc01f938b5e3283289b4a;hb=3e9ebc98a6bc02022900a8b2295e1a775d78ece0;hp=0772a5e32df3ca68653673b823a911eed2559088;hpb=1e36a6710aab710674e20fbd89f6a9a8f238c023;p=tools%2Fmedcoupling.git diff --git a/src/MEDCoupling/MEDCouplingSkyLineArray.hxx b/src/MEDCoupling/MEDCouplingSkyLineArray.hxx index 0772a5e32..7c7d04a03 100644 --- a/src/MEDCoupling/MEDCouplingSkyLineArray.hxx +++ b/src/MEDCoupling/MEDCouplingSkyLineArray.hxx @@ -1,4 +1,4 @@ -// Copyright (C) 2007-2015 CEA/DEN, EDF R&D +// Copyright (C) 2007-2016 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 @@ -23,34 +23,97 @@ #include "MEDCoupling.hxx" #include "MEDCouplingMemArray.hxx" #include "MCAuto.hxx" +#include "NormalizedGeometricTypes" #include namespace MEDCoupling { - class MEDCOUPLING_EXPORT MEDCouplingSkyLineArray + /**! + * 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. + * + * 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 { - private: - MCAuto _index; - MCAuto _value; public: - MEDCouplingSkyLineArray(); - MEDCouplingSkyLineArray( const MEDCouplingSkyLineArray &myArray ); - MEDCouplingSkyLineArray( const std::vector& index, const std::vector& value ); - MEDCouplingSkyLineArray( DataArrayInt* index, DataArrayInt* value ); - ~MEDCouplingSkyLineArray(); + 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 MEDCouplingSkyLineArray & other ); + + static MEDCouplingSkyLineArray * BuildFromPolyhedronConn( const DataArrayInt* c, const DataArrayInt* cI ); + + std::size_t getHeapMemorySizeWithoutChildren() const; + std::vector 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 _value->getNbOfElems(); } + int getLength() const { return _values->getNbOfElems(); } + + const int* getSuperIndex() const { return _super_index->begin(); } const int* getIndex() const { return _index->begin(); } - const int* getValue() const { return _value->begin(); } + const int* getValues() const { return _values->begin(); } + DataArrayInt* getSuperIndexArray() const; DataArrayInt* getIndexArray() const; - DataArrayInt* getValueArray() const; + DataArrayInt* getValuesArray() 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 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& 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; + + MCAuto _super_index; + MCAuto _index; + MCAuto _values; }; + } # endif