1 // MED MEDMEM : MED files in memory
3 // Copyright (C) 2003 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN,
4 // CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS
6 // This library is free software; you can redistribute it and/or
7 // modify it under the terms of the GNU Lesser General Public
8 // License as published by the Free Software Foundation; either
9 // version 2.1 of the License.
11 // This library is distributed in the hope that it will be useful,
12 // but WITHOUT ANY WARRANTY; without even the implied warranty of
13 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14 // Lesser General Public License for more details.
16 // You should have received a copy of the GNU Lesser General Public
17 // License along with this library; if not, write to the Free Software
18 // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
20 // See http://www.opencascade.org/SALOME/ or email : webmaster.salome@opencascade.org
24 // File : MEDMEM_ModulusArray.hxx
27 #ifndef __MEDMODULUSARRAY_H__
28 #define __MEDMODULUSARRAY_H__
30 #include "utilities.h"
33 This class is use to set cyclic (modulus length) array.
34 (array[length+1]==array[1])
36 We use it in particular to compare faces nodes lists to know if
37 they are the same (positive or negative cycle) !
41 class MEDMODULUSARRAY {
47 MEDMODULUSARRAY(int length, const int * array) ;
50 const int & operator[](const int &i) const ;
52 int compare(const MEDMODULUSARRAY &modulusArray) const;
56 MEDMODULUSARRAY::MEDMODULUSARRAY(int length, const int * array) :
57 _length(length), _array(array)
60 // for (int i=0;i<_length;i++){
61 // MESSAGE("MEDMODULUSARRAY["<<i<<"]="<<_array[i]);
65 MEDMODULUSARRAY::~MEDMODULUSARRAY()
67 // do nothing because nothing is allocated !
68 // MESSAGE("MEDMODULUSARRAY::~MEDMODULUSARRAY()") ;
72 const int & MEDMODULUSARRAY::operator[](const int &i) const
74 int position = i%_length ;
77 return _array[position] ;
80 int MEDMODULUSARRAY::compare(const MEDMODULUSARRAY &modulusArray) const
84 if (modulusArray._length != _length)
88 if (_array[0]==modulusArray[0])
94 if ((_array[0]==modulusArray[0])&(_array[1]==modulusArray[1]))
96 else if ((_array[0]==modulusArray[1])&(_array[1]==modulusArray[0]))
101 //search if there is one start point in common in two array
102 for(int i=0;i<_length;i++)
103 if ( _array[0] == modulusArray[i] ) {
104 // we search if cycle is the same
105 if (_array[1]==modulusArray[i+1]){ // positive order
107 for(int j=2;j<_length;j++)
108 if (_array[j]!=modulusArray[i+j]) {
112 } else if(_array[1]==modulusArray[i-1]) { //negative order
114 for(int j=2;j<_length;j++)
115 if (_array[j]!=modulusArray[i-j]) {
120 if (ret!=0) {// we have found it !
123 // else we continue if there is another start point i
128 # endif /* # ifndef __MEDMODULUSARRAY_H__ */