aimsalgo 6.0.0
Neuroimaging image processing
facet.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_MESH_FACET_H
36#define AIMS_MESH_FACET_H
37
39#include <aims/def/general.h>
40#include <aims/vector/vector.h>
41#include <aims/connectivity/connectivity.h>
42
44{
45 public:
46
47 Facet();
48 virtual ~Facet();
49
50 uint key() const;
51 bool equal( const Facet& other ) const;
52
53 Point3d& location() { return _location; }
54 const Point3d& location() const { return _location; }
55
56 byte& type() { return _type; }
57 byte type() const { return _type; }
58
59 short*& offset() { return _offset; }
60 short* offset() const { return _offset; }
61
62 uint& id() { return _id; }
63 uint id() const { return _id; }
64
65 void setNeighbor( Facet** pNeighor, int nNeighbor );
66 void setNeighbor( int nNeighbor );
67 int getNeighbor( const aims::Connectivity& connect,
68 Facet** pNeighor ) const;
69
70 Facet*& pNeighbor( int index ) { return _pNeighbor[ index ]; }
71 const Facet*& pNeighbor( int index ) const
72 { return (const Facet *&)_pNeighbor[ index ]; }
73
74 int nNeighbor() const { return _nNeighbor; }
75
76 protected:
77
79 byte _type;
80
83
85 short* _offset;
86};
87
88
89inline
91{
92 _nNeighbor = 0;
93 _pNeighbor = NULL;
94}
95
96
97inline
99{
100 if ( _pNeighbor )
101 delete [] _pNeighbor;
102}
103
104
105inline
107{
108 return ( (uint)_type << 29 ) |
109 ( 640000U * (uint)_location[ 2 ] +
110 800U * (uint)_location[ 1 ] +
111 (uint)_location[ 0 ] );
112}
113
114
115inline
116bool Facet::equal( const Facet& other ) const
117{
118 return _offset == other._offset && _type == other._type;
119}
120
121
122inline
124{
125 if ( _pNeighbor )
126 delete [] _pNeighbor;
127
129 _pNeighbor = new Facet*[ nNeighbor ];
130
131 memcpy( _pNeighbor, pNeighbor, nNeighbor * sizeof( Facet* ) );
132}
133
134
135inline
137{
139
140 if ( _pNeighbor )
141 delete [] _pNeighbor;
142 if ( nNeighbor > 0 )
143 _pNeighbor = new Facet*[ nNeighbor ];
144 else
145 _pNeighbor = 0;
146}
147
148
149inline
150std::ostream& operator << ( std::ostream& out, const Facet& thing )
151{
152 out << "{location=" << thing.location()
153 << ", type=" << (int)thing.type()
154 << ", offset=" << thing.offset()
155 << ", id=" << thing.id()
156 << ", nNeighbor=" << thing.nNeighbor()
157 << "(";
158 for ( int n = 0; n < thing.nNeighbor(); n++ )
159 out << thing.pNeighbor( n ) << ", ";
160 out << "NULL)}";
161
162 return out;
163}
164
165#endif
#define AIMSALGO_API
Definition facet.h:44
Point3d _location
Definition facet.h:78
virtual ~Facet()
Definition facet.h:98
int _nNeighbor
Definition facet.h:81
int getNeighbor(const aims::Connectivity &connect, Facet **pNeighor) const
bool equal(const Facet &other) const
Definition facet.h:116
int nNeighbor() const
Definition facet.h:74
short *& offset()
Definition facet.h:59
byte _type
Definition facet.h:79
const Point3d & location() const
Definition facet.h:54
Point3d & location()
Definition facet.h:53
Facet *& pNeighbor(int index)
Definition facet.h:70
short * _offset
Definition facet.h:85
const Facet *& pNeighbor(int index) const
Definition facet.h:71
uint _id
Definition facet.h:84
uint id() const
Definition facet.h:63
uint & id()
Definition facet.h:62
Facet()
Definition facet.h:90
byte & type()
Definition facet.h:56
byte type() const
Definition facet.h:57
Facet ** _pNeighbor
Definition facet.h:82
short * offset() const
Definition facet.h:60
uint key() const
Definition facet.h:106
void setNeighbor(Facet **pNeighor, int nNeighbor)
Definition facet.h:123
std::ostream & operator<<(std::ostream &out, const Facet &thing)
Definition facet.h:150
unsigned int uint
AimsVector< int16_t, 3 > Point3d