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 #include "MEDCouplingSkyLineArray.hxx"
24 using namespace MEDCoupling;
26 MEDCouplingSkyLineArray::MEDCouplingSkyLineArray():
27 _index( DataArrayInt::New() ), _values( DataArrayInt::New() ), _sub_values( DataArrayInt::New() )
31 MEDCouplingSkyLineArray::~MEDCouplingSkyLineArray()
35 MEDCouplingSkyLineArray* MEDCouplingSkyLineArray::New()
37 return new MEDCouplingSkyLineArray();
40 MEDCouplingSkyLineArray* MEDCouplingSkyLineArray::New( const std::vector<int>& index,
41 const std::vector<int>& value )
43 MEDCouplingSkyLineArray * ret = new MEDCouplingSkyLineArray();
44 ret->_index->reserve( index.size() );
45 ret->_index->insertAtTheEnd( index.begin(), index.end() );
46 ret->_values->reserve( value.size() );
47 ret->_values->insertAtTheEnd( value.begin(), value.end() );
51 MEDCouplingSkyLineArray* MEDCouplingSkyLineArray::New( DataArrayInt* index, DataArrayInt* value )
53 MEDCouplingSkyLineArray* ret = new MEDCouplingSkyLineArray();
54 ret->set(index, value);
58 MEDCouplingSkyLineArray* MEDCouplingSkyLineArray::New( const MEDCouplingSkyLineArray & other )
60 MEDCouplingSkyLineArray* ret = new MEDCouplingSkyLineArray();
61 ret->_index = other._index;
62 ret->_values = other._values;
63 ret->_sub_values = other._sub_values;
68 std::size_t MEDCouplingSkyLineArray::getHeapMemorySizeWithoutChildren() const
70 return _index->getHeapMemorySizeWithoutChildren()+_values->getHeapMemorySizeWithoutChildren()+_sub_values->getHeapMemorySizeWithoutChildren();
73 std::vector<const BigMemoryObject *> MEDCouplingSkyLineArray::getDirectChildrenWithNull() const
75 std::vector<const BigMemoryObject *> ret;
76 ret.push_back(_index);
77 ret.push_back(_values);
78 ret.push_back(_sub_values);
83 void MEDCouplingSkyLineArray::set( DataArrayInt* index, DataArrayInt* value )
87 if ( (DataArrayInt*)_index ) _index->incrRef();
88 else _index = DataArrayInt::New();
89 if ( (DataArrayInt*)_values ) _values->incrRef();
90 else _values = DataArrayInt::New();
93 DataArrayInt* MEDCouplingSkyLineArray::getIndexArray() const
95 return ((MEDCouplingSkyLineArray*)this)->_index;
98 DataArrayInt* MEDCouplingSkyLineArray::getValuesArray() const
100 return ((MEDCouplingSkyLineArray*)this)->_values;
103 std::string MEDCouplingSkyLineArray::simpleRepr() const
105 std::ostringstream oss;
106 oss << "MEDCouplingSkyLineArray" << std::endl;
107 oss << " Nb of items: " << getNumberOf() << std::endl;
108 oss << " Nb of values: " << getLength() << std::endl;
109 oss << " Index:" << std::endl;
111 const int * i = _index->begin();
112 for ( ; i != _index->end(); ++i )
115 oss << " Value:" << std::endl;
117 const int * v = _values->begin();
119 for ( i = _index->begin(); v != _values->end(); ++v, ++cnt )