Salome HOME
648accf623fd2b3a07bfdb6f7d7a7b9ee01bdb3b
[modules/geom.git] / src / GEOMImpl / GEOMImpl_IConformity.cxx
1 // Copyright (C) 2013-2023  CEA/DEN, EDF R&D, OPEN CASCADE
2 //
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.
7 //
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.
12 //
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
16 //
17 // See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
18 //
19 #include "GEOMImpl_IConformity.hxx"
20
21 //=============================================================================
22 /*!
23  *  SetListOfShapesIndices
24  *  Input 2D array of indexes converted into 1D array
25  */
26  //=============================================================================
27 void GEOMImpl_IConformity::SetListOfShapesIndices(const Handle(TColStd_HArray2OfInteger)& theArrayOfIndexes)
28 {
29   Handle(TColStd_HArray1OfInteger) anArray = new TColStd_HArray1OfInteger(1, theArrayOfIndexes->Size());
30
31   for (Standard_Integer aRow = 1; aRow <= theArrayOfIndexes->NbRows(); ++aRow)
32   {
33     anArray->SetValue(2 * aRow - 1, theArrayOfIndexes->Value(aRow, 1));
34     anArray->SetValue(2 * aRow, theArrayOfIndexes->Value(aRow, 2));
35   }
36
37   _func->SetIntegerArray(CHECKCONFORMITY_RET_LIST_OF_INDEXES, anArray);
38 }
39
40 //=============================================================================
41 /*!
42  *  GetListOfShapesIndices
43  *  Get cached 1D array of indexes and converted into 2D array of indexes
44  */
45  //=============================================================================
46 Handle(TColStd_HArray2OfInteger) GEOMImpl_IConformity::GetListOfShapesIndices()
47 {
48   Handle(TColStd_HArray1OfInteger) anArray = _func->GetIntegerArray(CHECKCONFORMITY_RET_LIST_OF_INDEXES);
49
50   Standard_Integer aLength = anArray->Size() / 2;
51   Handle(TColStd_HArray2OfInteger) aResArray = new TColStd_HArray2OfInteger(1, aLength, 1, 2);
52
53   for (Standard_Integer anIndex = 1; anIndex <= aLength; ++anIndex)
54   {
55     aResArray->SetValue(anIndex, 1, anArray->Value(2 * anIndex - 1));
56     aResArray->SetValue(anIndex, 2, anArray->Value(2 * anIndex));
57   }
58
59   return aResArray;
60 }