MeshSelectionT.hh 11.6 KB
Newer Older
Jan Möbius's avatar
Jan Möbius committed
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
/*===========================================================================*\
 *                                                                           *
 *                              OpenFlipper                                  *
 *      Copyright (C) 2001-2009 by Computer Graphics Group, RWTH Aachen      *
 *                           www.openflipper.org                             *
 *                                                                           *
 *---------------------------------------------------------------------------*
 *  This file is part of OpenFlipper.                                        *
 *                                                                           *
 *  OpenFlipper is free software: you can redistribute it and/or modify      *
 *  it under the terms of the GNU Lesser General Public License as           *
 *  published by the Free Software Foundation, either version 3 of           *
 *  the License, or (at your option) any later version with the              *
 *  following exceptions:                                                    *
 *                                                                           *
 *  If other files instantiate templates or use macros                       *
 *  or inline functions from this file, or you compile this file and         *
 *  link it with other files to produce an executable, this file does        *
 *  not by itself cause the resulting executable to be covered by the        *
 *  GNU Lesser General Public License. This exception does not however       *
 *  invalidate any other reasons why the executable file might be            *
 *  covered by the GNU Lesser General Public License.                        *
 *                                                                           *
 *  OpenFlipper is distributed in the hope that it will be useful,           *
 *  but WITHOUT ANY WARRANTY; without even the implied warranty of           *
 *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the            *
 *  GNU Lesser General Public License for more details.                      *
 *                                                                           *
 *  You should have received a copy of the GNU LesserGeneral Public          *
 *  License along with OpenFlipper. If not,                                  *
 *  see <http://www.gnu.org/licenses/>.                                      *
 *                                                                           *
\*===========================================================================*/

/*===========================================================================*\
 *                                                                           *
 *   $Revision$                                                         *
 *   $Author$                                                      *
 *   $Date$                   *
 *                                                                           *
\*===========================================================================*/
Jan Möbius's avatar
 
Jan Möbius committed
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57




//=============================================================================
//
//
//=============================================================================


#ifndef MESHSELECTION_HH
#define MESHSELECTION_HH


/*! \file MeshSelection.hh
    \brief Functions for selection on a mesh
58

Jan Möbius's avatar
 
Jan Möbius committed
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
*/

//== INCLUDES =================================================================

#include <vector>

//== FORWARDDECLARATIONS ======================================================

//== NAMESPACES ===============================================================

namespace MeshSelection {

//== DEFINITIONS ==============================================================

//===========================================================================
/** @name Vertex Selection
* @{ */
76
77
//===========================================================================

Jan Möbius's avatar
 
Jan Möbius committed
78
79
/// Select given vertices of a mesh
template< typename MeshT >
80
81
inline
void selectVertices(MeshT* _mesh, std::vector< int >& _vertices);
Jan Möbius's avatar
 
Jan Möbius committed
82
83
84

/// Unselect given vertices of a mesh
template< typename MeshT >
85
86
87
inline
void unselectVertices(MeshT* _mesh, std::vector< int >& _vertices);

Jan Möbius's avatar
 
Jan Möbius committed
88
89
/// Select all vertices of a mesh
template< typename MeshT >
90
inline
Jan Möbius's avatar
 
Jan Möbius committed
91
92
93
94
95
96
97
98
99
void selectAllVertices(MeshT* _mesh);

/// Set all vertices to unselected
template< typename MeshT >
inline
void clearVertexSelection(MeshT* _mesh);

/// invert vertex selection
template< typename MeshT >
100
inline
Jan Möbius's avatar
 
Jan Möbius committed
101
void invertVertexSelection(MeshT* _mesh);
102

Jan Möbius's avatar
 
Jan Möbius committed
103
104
105
106
107
108
/** Select all vertices of the mesh which are boundary vertices
 */
template< typename MeshT >
inline
void selectBoundaryVertices(MeshT* _mesh);

109
/** shrink the vertex selection
Jan Möbius's avatar
 
Jan Möbius committed
110
111
 */
template< typename MeshT >
112
inline
Jan Möbius's avatar
 
Jan Möbius committed
113
114
void shrinkVertexSelection(MeshT* _mesh) ;

115
/** grow the vertex selection
Jan Möbius's avatar
 
Jan Möbius committed
116
117
 */
template< typename MeshT >
118
inline
Jan Möbius's avatar
 
Jan Möbius committed
119
120
121
122
123
void growVertexSelection(MeshT* _mesh);

/** Get the current vertex selection
 */
template< typename MeshT >
124
inline
Jan Möbius's avatar
 
Jan Möbius committed
125
126
std::vector< int > getVertexSelection(MeshT* _mesh);

127
/** Get the current vertex selection
Jan Möbius's avatar
 
Jan Möbius committed
128
129
130
 * @param _invert if true : vector has been inverted to save mem
 */
template< typename MeshT >
131
inline
Jan Möbius's avatar
 
Jan Möbius committed
132
133
134
135
136
137
std::vector< int > getVertexSelection(MeshT* _mesh, bool& _invert);

/** Get the vertices connected to a given boundary edge
 * @param _vh handle of a boundary-edge
 */
template< typename MeshT >
138
inline
Jan Möbius's avatar
 
Jan Möbius committed
139
140
void selectBoundaryVertices(MeshT* _mesh, typename MeshT::VertexHandle& _vh);

141
142
143
144
145
146
147
148
/**
 * Select for each vertex in _vertices all incident edges
 * @param _vertices List of vertices to be converted
 */
template< typename MeshT >
inline
void convertVertexToEdgeSelection(MeshT* _mesh, std::vector< int >& _vertices);

149
150
151
152
153
154
155
/**
 * For each selected vertex select all incident edges
 */
template< typename MeshT >
inline
void convertVertexToEdgeSelection(MeshT* _mesh);

156
157
158
159
160
161
162
163
/**
 * Select for each vertex in _vertices all adjacent faces
 * @param _vertices List of vertices to be converted
 */
template< typename MeshT >
inline
void convertVertexToFaceSelection(MeshT* _mesh, std::vector< int >& _vertices);

164
165
166
167
168
169
170
/**
 * For each selected vertex select all adjacent faces
 */
template< typename MeshT >
inline
void convertVertexToFaceSelection(MeshT* _mesh);

171
/** @} */
Jan Möbius's avatar
 
Jan Möbius committed
172
173
174
175

//===========================================================================
/** @name Modeling Regions
* @{ */
176
//===========================================================================
Jan Möbius's avatar
 
Jan Möbius committed
177
178
179
180
181
182

/** Set the area bit for all defined vertices
 * @param _vertices The vertices belonging to the modeling area
 * @param _type Bit to be changed ( Normally Modeling area is OpenMesh::Attributes::UNUSED << 1 )
 * */
template< typename MeshT >
183
184
inline
void setArea(MeshT* _mesh, std::vector< int >& _vertices , unsigned int _type, bool _state);
Jan Möbius's avatar
 
Jan Möbius committed
185
186

/** Reset Modeling Status for vertices
187
 *
Jan Möbius's avatar
 
Jan Möbius committed
188
189
 * */
template< typename MeshT >
190
inline
Jan Möbius's avatar
 
Jan Möbius committed
191
192
193
194
195
void setArea(MeshT* _mesh , unsigned int _type, bool _state);

/** Get the current vertex selection
 */
template< typename MeshT >
196
inline
Jan Möbius's avatar
 
Jan Möbius committed
197
198
std::vector< int > getArea(MeshT* _mesh, unsigned int _type);

199
/** Get the current vertex selection
Jan Möbius's avatar
 
Jan Möbius committed
200
201
202
 * @param _invert if true : vector has been inverted to save mem
 */
template< typename MeshT >
203
inline
Jan Möbius's avatar
 
Jan Möbius committed
204
205
std::vector< int > getArea(MeshT* _mesh, unsigned int _type , bool& _invert);

206
/** @} */
Jan Möbius's avatar
 
Jan Möbius committed
207
208
209
210

//===========================================================================
/** @name Edge Selection
* @{ */
211
//===========================================================================
Jan Möbius's avatar
 
Jan Möbius committed
212
213
214

/// Select given edges of a mesh
template< typename MeshT >
215
216
inline
void selectEdges(MeshT* _mesh, std::vector< int >& _edges);
Jan Möbius's avatar
 
Jan Möbius committed
217
218
219

/// Unselect given edges of a mesh
template< typename MeshT >
220
221
inline
void unselectEdges(MeshT* _mesh, std::vector< int >& _edges);
Jan Möbius's avatar
 
Jan Möbius committed
222
223
224
225
226
227
228
229
230
231
232
233
234

/// Select all edges of a mesh
template< typename MeshT >
inline
void selectAllEdges(MeshT* _mesh);

///  Set all edges to unselected
template< typename MeshT >
inline
void clearEdgeSelection(MeshT* _mesh);

/// Invert Edge selection
template< typename MeshT >
235
inline
Jan Möbius's avatar
 
Jan Möbius committed
236
237
238
239
240
241
242
243
244
void invertEdgeSelection(MeshT* _mesh);

/// Select all boundary edges of a mesh
template< typename MeshT >
void selectBoundaryEdges(MeshT* _mesh);

/** Get the current edge selection
 */
template< typename MeshT >
245
inline
Jan Möbius's avatar
 
Jan Möbius committed
246
247
std::vector< int > getEdgeSelection(MeshT* _mesh);

248
/** Get the current edge selection
Jan Möbius's avatar
 
Jan Möbius committed
249
250
251
 * @param _invert if true : vector has been inverted to save mem
 */
template< typename MeshT >
252
inline
Jan Möbius's avatar
 
Jan Möbius committed
253
254
std::vector< int > getEdgeSelection(MeshT* _mesh, bool& _invert);

255
256
257
258
259
260
261
262
/**
 * Select for each edge in _edges all incident vertices
 * @param _edges List of edges to be converted
 */
template< typename MeshT >
inline
void convertEdgeToVertexSelection(MeshT* _mesh, std::vector< int >& _edges);

263
264
265
266
267
268
269
/**
 * For each selected edge select all incident vertices
 */
template< typename MeshT >
inline
void convertEdgeToVertexSelection(MeshT* _mesh);

270
271
272
273
274
275
276
277
/**
 * Select for each edge in _edges all adjacent faces
 * @param _edges List of edges to be converted
 */
template< typename MeshT >
inline
void convertEdgeToFaceSelection(MeshT* _mesh, std::vector< int >& _edges);

278
279
280
281
282
283
/**
 * For each selected edge select all adjacent faces
 */
template< typename MeshT >
inline
void convertEdgeToFaceSelection(MeshT* _mesh);
284
285

/** @} */
Jan Möbius's avatar
 
Jan Möbius committed
286
287
288
289

//===========================================================================
/** @name Face Selection
* @{ */
290
//===========================================================================
Jan Möbius's avatar
 
Jan Möbius committed
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313

/// Select given faces of a mesh
template< typename MeshT >
inline
void selectFaces(MeshT* _mesh, std::vector< int >& _faces );

/// Unselect given faces of a mesh
template< typename MeshT >
inline
void unselectFaces(MeshT* _mesh, std::vector< int >& _faces );

/// Select all faces of a mesh
template< typename MeshT >
inline
void selectAllFaces(MeshT* _mesh);

/// Set all faces to unselected
template< typename MeshT >
inline
void clearFaceSelection(MeshT* _mesh);

/// Invert face selection
template< typename MeshT >
314
inline
Jan Möbius's avatar
 
Jan Möbius committed
315
void invertFaceSelection(MeshT* _mesh);
316

Jan Möbius's avatar
 
Jan Möbius committed
317
318
319
320
321
/// Select all boundary faces of a mesh
template< typename MeshT >
void selectBoundaryFaces(MeshT* _mesh);

/** \brief Shrink Face selection
322
 *
Jan Möbius's avatar
 
Jan Möbius committed
323
324
325
 * Deselects all faces which are adjacent to a boundary vertex of the original selection
 */
template< typename MeshT >
326
inline
Jan Möbius's avatar
 
Jan Möbius committed
327
328
329
void shrinkFaceSelection(MeshT* _mesh);

/** \brief Grow Face selection
330
 *
Jan Möbius's avatar
 
Jan Möbius committed
331
332
333
 * Selects all faces which are adjacent to a vertex of a already selected face.
 */
template< typename MeshT >
334
inline
Jan Möbius's avatar
 
Jan Möbius committed
335
336
337
338
339
void growFaceSelection(MeshT* _mesh);

/** Get the current face selection
 */
template< typename MeshT >
340
inline
Jan Möbius's avatar
 
Jan Möbius committed
341
342
std::vector< int > getFaceSelection(MeshT* _mesh);

343
/** Get the current face selection
Jan Möbius's avatar
 
Jan Möbius committed
344
345
346
 * @param _invert if true : vector has been inverted to save mem
 */
template< typename MeshT >
347
inline
Jan Möbius's avatar
 
Jan Möbius committed
348
349
std::vector< int > getFaceSelection(MeshT* _mesh, bool& _invert);

350
351
352
353
354
355
356
357
358
/**
 * Select for each face in _faces all adjacent vertices
 * @param _faces List of faces to be converted
 */
template< typename MeshT >
inline
void convertFaceToVertexSelection(MeshT* _mesh, std::vector< int >& _faces);

/**
359
360
361
362
363
364
365
366
 * For each selected face select all adjacent vertices
 */
template< typename MeshT >
inline
void convertFaceToVertexSelection(MeshT* _mesh);

/**
 * For each selected face select all adjacent edges
367
368
369
 */
template< typename MeshT >
inline
370
void convertFaceToEdgeSelection(MeshT* _mesh);
371
/** @} */
Jan Möbius's avatar
 
Jan Möbius committed
372
373

//=============================================================================
374
} // MeshSelection Namespace
Jan Möbius's avatar
 
Jan Möbius committed
375
376
377
378
379
380
381
382
383
//=============================================================================
#if defined(INCLUDE_TEMPLATES) && !defined(MESHSELECTION_C)
#define MESHSELECTION_TEMPLATES
#include "MeshSelectionT.cc"
#endif
//=============================================================================
#endif // MESHSELECTION_HH defined
//=============================================================================