aimsalgo 6.0.0
Neuroimaging image processing
stlsort.h
Go to the documentation of this file.
1/* This software and supporting documentation are distributed by
2 * Institut Federatif de Recherche 49
3 * CEA/NeuroSpin, Batiment 145,
4 * 91191 Gif-sur-Yvette cedex
5 * France
6 *
7 * This software is governed by the CeCILL-B license under
8 * French law and abiding by the rules of distribution of free software.
9 * You can use, modify and/or redistribute the software under the
10 * terms of the CeCILL-B license as circulated by CEA, CNRS
11 * and INRIA at the following URL "http://www.cecill.info".
12 *
13 * As a counterpart to the access to the source code and rights to copy,
14 * modify and redistribute granted by the license, users are provided only
15 * with a limited warranty and the software's author, the holder of the
16 * economic rights, and the successive licensors have only limited
17 * liability.
18 *
19 * In this respect, the user's attention is drawn to the risks associated
20 * with loading, using, modifying and/or developing or reproducing the
21 * software by the user in light of its specific status of free software,
22 * that may mean that it is complicated to manipulate, and that also
23 * therefore means that it is reserved for developers and experienced
24 * professionals having in-depth computer knowledge. Users are therefore
25 * encouraged to load and test the software's suitability as regards their
26 * requirements in conditions enabling the security of their systems and/or
27 * data to be ensured and, more generally, to use and operate it in the
28 * same conditions as regards security.
29 *
30 * The fact that you are presently reading this means that you have had
31 * knowledge of the CeCILL-B license and that you accept its terms.
32 */
33
34
35#ifndef AIMS_DISTANCEMAP_STLSORT_H
36#define AIMS_DISTANCEMAP_STLSORT_H
37
38#include <aims/mesh/texture.h>
39#include <aims/mesh/surface.h>
40#include <aims/connectivity/connectivity.h>
41#include <set>
42#include <map>
43
44namespace aims
45{
46
47
48
49 //Def of the operator < for the Point3df (required by the map and the set)
51 : public std::binary_function<Point3df,Point3df, bool>
52 {
53 bool operator () ( const Point3df & p1, const Point3df & p2 ) const
54 {
55 return p1[2] < p2[2] ||
56 ( p1[2] == p2[2] &&
57 ( p1[1] < p2[1] ||
58 ( p1[1] == p2[1] &&
59 ( p1[0] < p2[0] ) ) ) );
60 }
61 };
62
63 //Def of the operator < for the Point3df (required by the map and the set)
64 struct Point3dCompare : public std::binary_function<Point3d,Point3d, bool>
65 {
66 bool operator () ( const Point3d & p1, const Point3d & p2 ) const
67 {
68 return p1[2] < p2[2] ||
69 ( p1[2] == p2[2] &&
70 ( p1[1] < p2[1] ||
71 ( p1[1] == p2[1] &&
72 ( p1[0] < p2[0] ) ) ) );
73 }
74 };
75
76 template <class T>
78: public std::binary_function<std::pair<T,T>, std::pair<T,T>, bool>
79{
80 bool operator () ( const std::pair<T,T> & p,
81 const std::pair<T,T> & r ) const
82 {
83 return p.first < r.first
84 || (p.first == r.first && p.second < r.second) ;
85
86 }
87 };
88
89// Def of the operator "<" for the set<T> (required by the map)
90template <class T>
92 : public std::binary_function<std::set<T>,std::set<T>, bool>
93{
94 bool operator () ( const std::set<T> & s1, const std::set<T> & s2 ) const
95 {
96 typename std::set<T>::iterator
97 is1=s1.begin(),es1=s1.end(),is2=s2.begin();
98 unsigned n1 = s1.size(), n2 = s2.size();
99 if (n1 != n2)
100 return (n1 < n2);
101 else
102 {
103 while ( ( is1 != es1) && ( (*is1) == (*is2) ) )
104 {
105 ++is1;
106 ++is2;
107 }
108 if (is1 != es1)
109 return( (*is1) < (*is2) );
110 else
111 return false;
112 }
113 }
114};
115
116
117//typedefs
118typedef std::set<Point3df,Point3dfCompare> Point3dfSet;
119typedef std::map<Point3df,Point3dfSet,Point3dfCompare> Point3dfNeigh;
120}
121
122#endif
std::set< Point3df, Point3dfCompare > Point3dfSet
Definition stlsort.h:118
std::map< Point3df, Point3dfSet, Point3dfCompare > Point3dfNeigh
Definition stlsort.h:119
bool operator()(const std::pair< T, T > &p, const std::pair< T, T > &r) const
Definition stlsort.h:80
bool operator()(const Point3d &p1, const Point3d &p2) const
Definition stlsort.h:66
bool operator()(const Point3df &p1, const Point3df &p2) const
Definition stlsort.h:53
bool operator()(const std::set< T > &s1, const std::set< T > &s2) const
Definition stlsort.h:94
AimsVector< float, 3 > Point3df
AimsVector< int16_t, 3 > Point3d