Commit c87834d1 authored by Mike Kremer's avatar Mike Kremer

Added conversion functions that allow the conversion from vertex, edge and...

Added conversion functions that allow the conversion from vertex, edge and face selections to halfedge selections (and vice versa).

git-svn-id: http://www.openflipper.org/svnrepo/OpenFlipper/branches/Free@10935 383ad7c9-94d9-4d36-a494-682f7c89f535
parent e436934b
......@@ -301,6 +301,41 @@ void convertVertexToEdgeSelection(MeshT* _mesh) {
}
}
template< typename MeshT >
inline
void convertVertexToHalfedgeSelection(MeshT* _mesh, std::vector< int >& _vertices) {
for (std::vector<int>::iterator v = _vertices.begin(); v != _vertices.end(); ++v) {
typename MeshT::VertexHandle vh(*v);
typename MeshT::VertexEdgeIter e_iter = _mesh->ve_iter(vh);
for (; e_iter; ++e_iter) {
_mesh->status(_mesh->halfedge_handle(e_iter, 0)).set_selected(true);
_mesh->status(_mesh->halfedge_handle(e_iter, 1)).set_selected(true);
}
}
}
template< typename MeshT >
inline
void convertVertexToHalfedgeSelection(MeshT* _mesh) {
typename MeshT::VertexIter v_it, v_end = _mesh->vertices_end();
for (v_it = _mesh->vertices_begin(); v_it != v_end; ++v_it)
if ( _mesh->status( v_it ).selected() ){
typename MeshT::VertexEdgeIter e_iter = _mesh->ve_iter(v_it);
for (; e_iter; ++e_iter) {
_mesh->status(_mesh->halfedge_handle(e_iter, 0)).set_selected(true);
_mesh->status(_mesh->halfedge_handle(e_iter, 1)).set_selected(true);
}
}
}
template< typename MeshT >
inline
void convertVertexToFaceSelection(MeshT* _mesh, std::vector< int >& _vertices) {
......@@ -581,6 +616,19 @@ void convertEdgeToFaceSelection(MeshT* _mesh) {
}
}
template< typename MeshT >
inline
void convertEdgeToHalfedgeSelection(MeshT* _mesh) {
for ( typename MeshT::EdgeIter e_it= _mesh->edges_begin() ; e_it != _mesh->edges_end() ; ++e_it )
if ( _mesh->status(e_it).selected() ){
_mesh->status(_mesh->halfedge_handle(e_it, 0)).set_selected(true);
_mesh->status(_mesh->halfedge_handle(e_it, 1)).set_selected(true);
}
}
//=========================================================
......@@ -673,6 +721,43 @@ std::vector< int > getHalfedgeSelection(MeshT* _mesh) {
return selection;
}
template< typename MeshT >
inline
void convertHalfedgeToVertexSelection(MeshT* _mesh) {
for ( typename MeshT::HalfedgeIter he_it= _mesh->halfedges_begin() ; he_it != _mesh->halfedges_end() ; ++he_it ) {
if(_mesh->status(he_it).selected()) {
_mesh->status(_mesh->to_vertex_handle(he_it)).set_selected(true);
_mesh->status(_mesh->from_vertex_handle(he_it)).set_selected(true);
}
}
}
template< typename MeshT >
inline
void convertHalfedgeToEdgeSelection(MeshT* _mesh) {
for ( typename MeshT::HalfedgeIter he_it= _mesh->halfedges_begin() ; he_it != _mesh->halfedges_end() ; ++he_it ) {
if(_mesh->status(he_it).selected()) {
_mesh->status(_mesh->edge_handle(he_it)).set_selected(true);
}
}
}
template< typename MeshT >
inline
void convertHalfedgeToFaceSelection(MeshT* _mesh) {
for ( typename MeshT::HalfedgeIter he_it= _mesh->halfedges_begin() ; he_it != _mesh->halfedges_end() ; ++he_it ) {
if(_mesh->status(he_it).selected()) {
_mesh->status(_mesh->face_handle(he_it)).set_selected(true);
}
}
}
//=========================================================
//== Face Selection =======================================
//=========================================================
......@@ -916,6 +1001,21 @@ void convertFaceToEdgeSelection(MeshT* _mesh) {
}
}
template< typename MeshT >
inline
void convertFaceToHalfedgeSelection(MeshT* _mesh) {
for ( typename MeshT::FaceIter f_it= _mesh->faces_begin() ; f_it != _mesh->faces_end() ; ++f_it )
if ( _mesh->status(f_it).selected() ){
typename MeshT::FaceHalfedgeIter fh_iter = _mesh->fh_iter(f_it);
for (; fh_iter; ++fh_iter)
_mesh->status(fh_iter).set_selected(true);
}
}
//=============================================================================
} // MeshSelection Namespace
//=============================================================================
......@@ -153,6 +153,21 @@ template< typename MeshT >
inline
void convertVertexToEdgeSelection(MeshT* _mesh);
/**
* 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);
/**
* Select for each vertex in _vertices all adjacent faces
* @param _vertices List of vertices to be converted
......@@ -282,6 +297,13 @@ template< typename MeshT >
inline
void convertEdgeToFaceSelection(MeshT* _mesh);
/**
* For each selected edge select all halfedges
*/
template< typename MeshT >
inline
void convertEdgeToHalfedgeSelection(MeshT* _mesh);
/** @} */
......@@ -326,6 +348,27 @@ template< typename MeshT >
inline
std::vector< int > getHalfedgeSelection(MeshT* _mesh);
/**
* 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);
//===========================================================================
/** @name Face Selection
* @{ */
......@@ -410,6 +453,14 @@ void convertFaceToVertexSelection(MeshT* _mesh);
template< typename MeshT >
inline
void convertFaceToEdgeSelection(MeshT* _mesh);
/**
* For each selected face select all incident halfedges
*/
template< typename MeshT >
inline
void convertFaceToHalfedgeSelection(MeshT* _mesh);
/** @} */
//=============================================================================
......
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