Commit 10c9de60 authored by David Bommes's avatar David Bommes

added halfedge functions

git-svn-id: http://www.openflipper.org/svnrepo/OpenFlipper/branches/Free@9992 383ad7c9-94d9-4d36-a494-682f7c89f535
parent 0517ea47
......@@ -581,6 +581,98 @@ void convertEdgeToFaceSelection(MeshT* _mesh) {
}
}
//=========================================================
//== Halfedge Selection =====================================
//=========================================================
template< typename MeshT >
inline
void selectHalfedges(MeshT* _mesh, std::vector< int >& _halfedges) {
const int n_halfedges = (int)_mesh->n_halfedges();
for ( uint i = 0 ; i < _halfedges.size() ; ++i )
if ( (_halfedges[i] > 0) && ( _halfedges[i] < n_halfedges ) ) {
typename MeshT::HalfedgeHandle heh(_halfedges[i]);
_mesh->status(heh).set_selected(true);
}
}
//=========================================================
template< typename MeshT >
inline
void unselectHalfedges(MeshT* _mesh, std::vector< int >& _halfedges) {
const int n_halfedges = (int)_mesh->n_halfedges();
for ( uint i = 0 ; i < _halfedges.size() ; ++i )
if ( (_halfedges[i] > 0) && ( _halfedges[i] < n_halfedges ) ) {
typename MeshT::HalfedgeHandle heh(_halfedges[i]);
_mesh->status(heh).set_selected(false);
}
}
//=========================================================
template< typename MeshT >
inline
void selectAllHalfedges(MeshT* _mesh) {
typename MeshT::HalfedgeIter he_it, he_end=_mesh->halfedges_end();
for (he_it = _mesh->halfedges_begin(); he_it != he_end ; ++he_it)
_mesh->status(he_it).set_selected(true);
}
//=========================================================
template< typename MeshT >
inline
void clearHalfedgeSelection(MeshT* _mesh) {
typename MeshT::HalfedgeIter he_it, he_end=_mesh->halfedges_end();
for (he_it = _mesh->halfedges_begin(); he_it != he_end ; ++he_it)
_mesh->status(he_it).set_selected(false);
}
//=========================================================
template< typename MeshT >
inline
void invertHalfedgeSelection(MeshT* _mesh) {
typename MeshT::HalfedgeIter he_it, he_end=_mesh->halfedges_end();
for (he_it = _mesh->halfedges_begin(); he_it != he_end ; ++he_it)
_mesh->status(he_it).set_selected( ! _mesh->status(he_it).selected());
}
//=========================================================
template< typename MeshT >
inline
void selectBoundaryHalfedges(MeshT* _mesh) {
typename MeshT::HalfedgeIter he_it, he_end=_mesh->halfedges_end();
for (he_it = _mesh->halfedges_begin(); he_it != he_end ; ++he_it)
if ( _mesh->is_boundary( he_it))
_mesh->status(he_it).set_selected( true );
}
//=========================================================
template< typename MeshT >
inline
std::vector< int > getHalfedgeSelection(MeshT* _mesh) {
std::vector< int > selection;
for ( typename MeshT::HalfedgeIter he_it= _mesh->halfedges_begin() ; he_it != _mesh->halfedges_end() ; ++he_it )
if ( _mesh->status(he_it).selected() )
selection.push_back( he_it.handle().idx() );
return selection;
}
//=========================================================
//== Face Selection =======================================
//=========================================================
......
......@@ -282,8 +282,50 @@ template< typename MeshT >
inline
void convertEdgeToFaceSelection(MeshT* _mesh);
/** @} */
//===========================================================================
/** @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);
//===========================================================================
/** @name Face Selection
* @{ */
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment