MeshSelectionT.hh 14.8 KB
Newer Older
Jan Möbius's avatar
Jan Möbius committed
1
/*===========================================================================*\
Jan Möbius's avatar
Jan Möbius committed
2 3
*                                                                            *
*                              OpenFlipper                                   *
Jan Möbius's avatar
Jan Möbius committed
4
*      Copyright (C) 2001-2011 by Computer Graphics Group, RWTH Aachen       *
Jan Möbius's avatar
Jan Möbius committed
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
*                           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/>.                                       *
*                                                                            *
Jan Möbius's avatar
Jan Möbius committed
33 34 35
\*===========================================================================*/

/*===========================================================================*\
Jan Möbius's avatar
Jan Möbius committed
36 37 38 39 40
*                                                                            *
*   $Revision$                                                       *
*   $LastChangedBy$                                                *
*   $Date$                     *
*                                                                            *
Jan Möbius's avatar
Jan Möbius committed
41
\*===========================================================================*/
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 164 165 166 167 168 169 170
/**
 * Select for each vertex in _vertices all incident halfedges
 * @param _vertices List of vertices to be converted
 */
template< typename MeshT >
inline
void convertVertexToHalfedgeSelection(MeshT* _mesh, std::vector< int >& _vertices);

/**
 * For each selected vertex select all incident halfedges
 */
template< typename MeshT >
inline
void convertVertexToHalfedgeSelection(MeshT* _mesh);

171 172 173 174 175 176 177 178
/**
 * 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);

179 180 181 182 183 184 185
/**
 * For each selected vertex select all adjacent faces
 */
template< typename MeshT >
inline
void convertVertexToFaceSelection(MeshT* _mesh);

186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206
/**
 * Convert vertex selection to feature selection
 */
template< typename MeshT >
inline
void convertVertexSelectionToFeatureVertices(MeshT* _mesh);

/**
 * Convert feature selection to vertex selection
 */
template< typename MeshT >
inline
void convertFeatureVerticesToVertexSelection(MeshT* _mesh);

/**
 * Clear all features
 */
template< typename MeshT >
inline
void clearFeatureVertices(MeshT* _mesh);

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

//===========================================================================
/** @name Modeling Regions
* @{ */
212
//===========================================================================
Jan Möbius's avatar
 
Jan Möbius committed
213 214 215 216 217 218

/** 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 >
219 220
inline
void setArea(MeshT* _mesh, std::vector< int >& _vertices , unsigned int _type, bool _state);
Jan Möbius's avatar
 
Jan Möbius committed
221 222

/** Reset Modeling Status for vertices
223
 *
Jan Möbius's avatar
 
Jan Möbius committed
224 225
 * */
template< typename MeshT >
226
inline
Jan Möbius's avatar
 
Jan Möbius committed
227 228 229 230 231
void setArea(MeshT* _mesh , unsigned int _type, bool _state);

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

235
/** Get the current vertex selection
Jan Möbius's avatar
 
Jan Möbius committed
236 237 238
 * @param _invert if true : vector has been inverted to save mem
 */
template< typename MeshT >
239
inline
Jan Möbius's avatar
 
Jan Möbius committed
240 241
std::vector< int > getArea(MeshT* _mesh, unsigned int _type , bool& _invert);

242
/** @} */
Jan Möbius's avatar
 
Jan Möbius committed
243 244 245 246

//===========================================================================
/** @name Edge Selection
* @{ */
247
//===========================================================================
Jan Möbius's avatar
 
Jan Möbius committed
248 249 250

/// Select given edges of a mesh
template< typename MeshT >
251 252
inline
void selectEdges(MeshT* _mesh, std::vector< int >& _edges);
Jan Möbius's avatar
 
Jan Möbius committed
253 254 255

/// Unselect given edges of a mesh
template< typename MeshT >
256 257
inline
void unselectEdges(MeshT* _mesh, std::vector< int >& _edges);
Jan Möbius's avatar
 
Jan Möbius committed
258 259 260 261 262 263 264 265 266 267 268 269 270

/// 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 >
271
inline
Jan Möbius's avatar
 
Jan Möbius committed
272 273 274 275 276 277 278 279 280
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 >
281
inline
Jan Möbius's avatar
 
Jan Möbius committed
282 283
std::vector< int > getEdgeSelection(MeshT* _mesh);

284
/** Get the current edge selection
Jan Möbius's avatar
 
Jan Möbius committed
285 286 287
 * @param _invert if true : vector has been inverted to save mem
 */
template< typename MeshT >
288
inline
Jan Möbius's avatar
 
Jan Möbius committed
289 290
std::vector< int > getEdgeSelection(MeshT* _mesh, bool& _invert);

291 292 293 294 295 296 297 298
/**
 * 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);

299 300 301 302 303 304 305
/**
 * For each selected edge select all incident vertices
 */
template< typename MeshT >
inline
void convertEdgeToVertexSelection(MeshT* _mesh);

306 307 308 309 310 311 312 313
/**
 * 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);

314 315 316 317 318 319
/**
 * For each selected edge select all adjacent faces
 */
template< typename MeshT >
inline
void convertEdgeToFaceSelection(MeshT* _mesh);
320

321 322 323 324 325 326 327
/**
 * For each selected edge select all halfedges
 */
template< typename MeshT >
inline
void convertEdgeToHalfedgeSelection(MeshT* _mesh);

328 329 330 331 332
/**
 * Convert edge selection to feature selection
 */
template< typename MeshT >
inline
333
void convertEdgeSelectionToFeatureEdges(MeshT* _mesh);
334 335 336 337 338 339

/**
 * Convert feature selection to edge selection
 */
template< typename MeshT >
inline
340
void convertFeatureEdgesToEdgeSelection(MeshT* _mesh);
341 342 343 344 345 346

/**
 * Clear all features
 */
template< typename MeshT >
inline
347
void clearFeatureEdges(MeshT* _mesh);
David Bommes's avatar
David Bommes committed
348 349


350
/** @} */
Jan Möbius's avatar
 
Jan Möbius committed
351

David Bommes's avatar
David Bommes committed
352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391
//===========================================================================
/** @name Halfedge Selection
* @{ */
//===========================================================================

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

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

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

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

/// Invert Edge selection
template< typename MeshT >
inline
void invertHalfedgeSelection(MeshT* _mesh);

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

/** Get the current edge selection
 */
template< typename MeshT >
inline
std::vector< int > getHalfedgeSelection(MeshT* _mesh);

392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412
/**
 * For each halfedge select all incident vertices
 */
template< typename MeshT >
inline
void convertHalfedgeToVertexSelection(MeshT* _mesh);

/**
 * For each halfedge select all edges
 */
template< typename MeshT >
inline
void convertHalfedgeToEdgeSelection(MeshT* _mesh);

/**
 * For each halfedge select all incident faces
 */
template< typename MeshT >
inline
void convertHalfedgeToFaceSelection(MeshT* _mesh);

Jan Möbius's avatar
 
Jan Möbius committed
413 414 415
//===========================================================================
/** @name Face Selection
* @{ */
416
//===========================================================================
Jan Möbius's avatar
 
Jan Möbius committed
417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439

/// 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 >
440
inline
Jan Möbius's avatar
 
Jan Möbius committed
441
void invertFaceSelection(MeshT* _mesh);
442

Jan Möbius's avatar
 
Jan Möbius committed
443 444 445 446 447
/// Select all boundary faces of a mesh
template< typename MeshT >
void selectBoundaryFaces(MeshT* _mesh);

/** \brief Shrink Face selection
448
 *
Jan Möbius's avatar
 
Jan Möbius committed
449 450 451
 * Deselects all faces which are adjacent to a boundary vertex of the original selection
 */
template< typename MeshT >
452
inline
Jan Möbius's avatar
 
Jan Möbius committed
453 454 455
void shrinkFaceSelection(MeshT* _mesh);

/** \brief Grow Face selection
456
 *
Jan Möbius's avatar
 
Jan Möbius committed
457 458 459
 * Selects all faces which are adjacent to a vertex of a already selected face.
 */
template< typename MeshT >
460
inline
Jan Möbius's avatar
 
Jan Möbius committed
461 462 463 464 465
void growFaceSelection(MeshT* _mesh);

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

469
/** Get the current face selection
Jan Möbius's avatar
 
Jan Möbius committed
470 471 472
 * @param _invert if true : vector has been inverted to save mem
 */
template< typename MeshT >
473
inline
Jan Möbius's avatar
 
Jan Möbius committed
474 475
std::vector< int > getFaceSelection(MeshT* _mesh, bool& _invert);

476 477 478 479 480 481 482 483 484
/**
 * 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);

/**
485 486 487 488 489 490 491 492
 * For each selected face select all adjacent vertices
 */
template< typename MeshT >
inline
void convertFaceToVertexSelection(MeshT* _mesh);

/**
 * For each selected face select all adjacent edges
493 494 495
 */
template< typename MeshT >
inline
496
void convertFaceToEdgeSelection(MeshT* _mesh);
497 498 499 500 501 502 503 504

/**
 * For each selected face select all incident halfedges
 */
template< typename MeshT >
inline
void convertFaceToHalfedgeSelection(MeshT* _mesh);

505 506 507 508 509 510 511 512 513 514 515 516 517 518 519 520 521 522 523 524 525
/**
 * Convert face selection to feature selection
 */
template< typename MeshT >
inline
void convertFaceSelectionToFeatureFaces(MeshT* _mesh);

/**
 * Convert feature selection to edge selection
 */
template< typename MeshT >
inline
void convertFeatureFacesToFaceSelection(MeshT* _mesh);

/**
 * Clear all features
 */
template< typename MeshT >
inline
void clearFeatureFaces(MeshT* _mesh);

526
/** @} */
Jan Möbius's avatar
 
Jan Möbius committed
527 528

//=============================================================================
529
} // MeshSelection Namespace
Jan Möbius's avatar
 
Jan Möbius committed
530 531 532 533 534 535 536 537 538
//=============================================================================
#if defined(INCLUDE_TEMPLATES) && !defined(MESHSELECTION_C)
#define MESHSELECTION_TEMPLATES
#include "MeshSelectionT.cc"
#endif
//=============================================================================
#endif // MESHSELECTION_HH defined
//=============================================================================