Version: 9.16.0
AdjacentFunctor.hxx
Go to the documentation of this file.
1// Copyright (C) 2007-2026 CEA, EDF, OPEN CASCADE
2//
3// Copyright (C) 2003-2007 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN,
4// CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS
5//
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, or (at your option) any later version.
10//
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.
15//
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
19//
20// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
21//
22
23// File : AdjacentFunctor.hxx
24// Author : Eric Fayolle (EDF)
25// Module : KERNEL
26// Modified by : $LastChangedBy$
27// Date : $LastChangedDate: 2007-01-24 16:30:34 +0100 (mer, 24 jan 2007) $
28// Id : $Id$
29//
30#ifndef _ADJACENT_FUNCTOR_HXX_
31#define _ADJACENT_FUNCTOR_HXX_
32
33#include "ConstTraits.hxx"
34// Pour affichage
35#include "DisplayPair.hxx"
36//
37#include "utilities.h"
38
39// Suppose que le container est trié
40template < typename T > struct AdjacentFunctor {
41
43 const T & _minValue;
48
49 AdjacentFunctor(const T& value):_minValue(value),_maxValue(value),
50 _minFound(false),_maxFound(false),
51 _equal(false) {}
52
53 // Suppose que les valeurs passées en paramètres sont triées par ordre croissant
54 bool operator()(const T &v1) {
55 if (SALOME::VerbosityActivated())
56 {
57 std::cout << "AdjacentFunctor: " << _minValue << _maxValue << std::endl;
58 std::cout << "AdjacentFunctor: " << _min << _max << std::endl;
59 }
60
61 if ( v1 <= _minValue && v1 >= _maxValue)
62 {
63 _equal= true;
64
65 if (SALOME::VerbosityActivated())
66 std::cout << "AdjacentFunctor: _equal : " << v1 << std::endl;
67
68 return true;
69 }
70 if ( v1 < _minValue )
71 {
72 _min=v1;_minFound=true;
73
74 if (SALOME::VerbosityActivated())
75 std::cout << "AdjacentFunctor: _minFound : " <<_min << std::endl;
76 }
77 else if ( v1 > _maxValue )
78 {
79 _max=v1;_maxFound=true;
80
81 if (SALOME::VerbosityActivated())
82 std::cout << "AdjacentFunctor: _maxFound : " <<_max << std::endl;
83 }
84
85
86 /*
87 if ( v1 < _minValue) {
88 std::cout << "EE1: _min : " << _min << std::endl;
89 _min=v1;_minFound=true;
90 std::cout << "AdjacentFunctor: _minFound : " <<_min << ", _minValue " << _minValue << std::endl;
91 } else if ( v1 > _maxValue ) {
92 _max=v1;_maxFound=true;
93 std::cout << "AdjacentFunctor: _maxFound : " <<_max << ", _maxValue " << _maxValue << std::endl;
94 } else {
95 _equal= true;
96 std::cout << "AdjacentFunctor: _equal : " << v1<< ", _minValue " << _minValue << ", _maxValue " << _maxValue << std::endl;
97 return true;
98 } // end if
99 */
100
101 //std::cout << "AdjacentFunctor: _minFound : " <<_min << ", _maxFound " << _max << std::endl;
102 return ( _minFound && _maxFound );
103 }
104
105 void setMaxValue(const T & value) {_maxValue = value;}
106 bool isEqual() const { return _equal;}
107 bool isBounded() const { return _minFound && _maxFound;}
108 bool getBounds(TNoConst & min, TNoConst & max) const {
109 if (SALOME::VerbosityActivated())
110 std::cout << "_minFound : " <<_minFound << ", _maxFound " << _maxFound << std::endl;
111
112 if (_minFound && _maxFound ) { min=_min; max=_max; return true; }
113 return false;
114 }
115 void reset() { _minFound = false; _maxFound = false; _equal = false; };
116};
117
118#endif
Definition: AdjacentFunctor.hxx:40
bool isEqual() const
Definition: AdjacentFunctor.hxx:106
void setMaxValue(const T &value)
Definition: AdjacentFunctor.hxx:105
AdjacentFunctor(const T &value)
Definition: AdjacentFunctor.hxx:49
bool _minFound
Definition: AdjacentFunctor.hxx:47
bool _maxFound
Definition: AdjacentFunctor.hxx:47
const T & _minValue
Definition: AdjacentFunctor.hxx:43
T _maxValue
Definition: AdjacentFunctor.hxx:44
bool _equal
Definition: AdjacentFunctor.hxx:47
ConstTrait< T >::NonConstType TNoConst
Definition: AdjacentFunctor.hxx:42
TNoConst _max
Definition: AdjacentFunctor.hxx:45
TNoConst _min
Definition: AdjacentFunctor.hxx:46
void reset()
Definition: AdjacentFunctor.hxx:115
bool getBounds(TNoConst &min, TNoConst &max) const
Definition: AdjacentFunctor.hxx:108
bool operator()(const T &v1)
Definition: AdjacentFunctor.hxx:54
bool isBounded() const
Definition: AdjacentFunctor.hxx:107
T NonConstType
Definition: ConstTraits.hxx:33