Commit 3d30114c authored by Dirk Wilden's avatar Dirk Wilden
Browse files

more efficient selection conversion

git-svn-id: http://www.openflipper.org/svnrepo/OpenFlipper/branches/Free@8634 383ad7c9-94d9-4d36-a494-682f7c89f535
parent 74691666
...@@ -273,15 +273,32 @@ template< typename MeshT > ...@@ -273,15 +273,32 @@ template< typename MeshT >
inline inline
void convertVertexToEdgeSelection(MeshT* _mesh, std::vector< int >& _vertices) { void convertVertexToEdgeSelection(MeshT* _mesh, std::vector< int >& _vertices) {
for (std::vector<int>::iterator v = _vertices.begin(); v != _vertices.end(); ++v) { for (std::vector<int>::iterator v = _vertices.begin(); v != _vertices.end(); ++v) {
typename MeshT::VertexHandle vh(*v); typename MeshT::VertexHandle vh(*v);
typename MeshT::VertexEdgeIter e_iter = _mesh->ve_iter(vh); typename MeshT::VertexEdgeIter e_iter = _mesh->ve_iter(vh);
for (; e_iter; ++e_iter) { for (; e_iter; ++e_iter) {
_mesh->status(e_iter).set_selected(true); _mesh->status(e_iter).set_selected(true);
} }
} }
}
template< typename MeshT >
inline
void convertVertexToEdgeSelection(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(e_iter).set_selected(true);
}
} }
template< typename MeshT > template< typename MeshT >
...@@ -299,6 +316,23 @@ void convertVertexToFaceSelection(MeshT* _mesh, std::vector< int >& _vertices) { ...@@ -299,6 +316,23 @@ void convertVertexToFaceSelection(MeshT* _mesh, std::vector< int >& _vertices) {
} }
} }
template< typename MeshT >
inline
void convertVertexToFaceSelection(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::VertexFaceIter f_iter = _mesh->vf_iter(v_it);
for (; f_iter; ++f_iter)
_mesh->status(f_iter).set_selected(true);
}
}
//========================================================= //=========================================================
//== Modeling Regions ===================================== //== Modeling Regions =====================================
//========================================================= //=========================================================
...@@ -491,6 +525,24 @@ void convertEdgeToVertexSelection(MeshT* _mesh, std::vector< int >& _edges) { ...@@ -491,6 +525,24 @@ void convertEdgeToVertexSelection(MeshT* _mesh, std::vector< int >& _edges) {
} }
} }
template< typename MeshT >
inline
void convertEdgeToVertexSelection(MeshT* _mesh) {
for ( typename MeshT::EdgeIter e_it= _mesh->edges_begin() ; e_it != _mesh->edges_end() ; ++e_it )
if ( _mesh->status(e_it).selected() ){
typename MeshT::HalfedgeHandle heh0 = _mesh->halfedge_handle(e_it.handle(), 0);
typename MeshT::VertexHandle vh0 = _mesh->to_vertex_handle(heh0);
typename MeshT::VertexHandle vh1 = _mesh->from_vertex_handle(heh0);
_mesh->status(vh0).set_selected(true);
_mesh->status(vh1).set_selected(true);
}
}
template< typename MeshT > template< typename MeshT >
inline inline
void convertEdgeToFaceSelection(MeshT* _mesh, std::vector< int >& _edges) { void convertEdgeToFaceSelection(MeshT* _mesh, std::vector< int >& _edges) {
...@@ -509,6 +561,25 @@ void convertEdgeToFaceSelection(MeshT* _mesh, std::vector< int >& _edges) { ...@@ -509,6 +561,25 @@ void convertEdgeToFaceSelection(MeshT* _mesh, std::vector< int >& _edges) {
} }
} }
template< typename MeshT >
inline
void convertEdgeToFaceSelection(MeshT* _mesh) {
for ( typename MeshT::EdgeIter e_it= _mesh->edges_begin() ; e_it != _mesh->edges_end() ; ++e_it )
if ( _mesh->status(e_it).selected() ){
typename MeshT::HalfedgeHandle heh0 = _mesh->halfedge_handle(e_it.handle(), 0);
typename MeshT::HalfedgeHandle heh1 = _mesh->halfedge_handle(e_it.handle(), 1);
typename MeshT::FaceHandle fh0 = _mesh->face_handle(heh0);
typename MeshT::FaceHandle fh1 = _mesh->face_handle(heh1);
_mesh->status(fh0).set_selected(true);
_mesh->status(fh1).set_selected(true);
}
}
//========================================================= //=========================================================
//== Face Selection ======================================= //== Face Selection =======================================
...@@ -707,6 +778,21 @@ void convertFaceToVertexSelection(MeshT* _mesh, std::vector< int >& _faces) { ...@@ -707,6 +778,21 @@ void convertFaceToVertexSelection(MeshT* _mesh, std::vector< int >& _faces) {
} }
} }
template< typename MeshT >
inline
void convertFaceToVertexSelection(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::FaceVertexIter v_iter = _mesh->fv_iter(f_it);
for (; v_iter; ++v_iter)
_mesh->status(v_iter).set_selected(true);
}
}
template< typename MeshT > template< typename MeshT >
inline inline
void convertFaceToEdgeSelection(MeshT* _mesh, std::vector< int >& _faces) { void convertFaceToEdgeSelection(MeshT* _mesh, std::vector< int >& _faces) {
...@@ -723,6 +809,21 @@ void convertFaceToEdgeSelection(MeshT* _mesh, std::vector< int >& _faces) { ...@@ -723,6 +809,21 @@ void convertFaceToEdgeSelection(MeshT* _mesh, std::vector< int >& _faces) {
} }
} }
template< typename MeshT >
inline
void convertFaceToEdgeSelection(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::FaceEdgeIter e_iter = _mesh->fe_iter(f_it);
for (; e_iter; ++e_iter)
_mesh->status(e_iter).set_selected(true);
}
}
//============================================================================= //=============================================================================
} // MeshSelection Namespace } // MeshSelection Namespace
//============================================================================= //=============================================================================
...@@ -146,6 +146,13 @@ template< typename MeshT > ...@@ -146,6 +146,13 @@ template< typename MeshT >
inline inline
void convertVertexToEdgeSelection(MeshT* _mesh, std::vector< int >& _vertices); void convertVertexToEdgeSelection(MeshT* _mesh, std::vector< int >& _vertices);
/**
* For each selected vertex select all incident edges
*/
template< typename MeshT >
inline
void convertVertexToEdgeSelection(MeshT* _mesh);
/** /**
* Select for each vertex in _vertices all adjacent faces * Select for each vertex in _vertices all adjacent faces
* @param _vertices List of vertices to be converted * @param _vertices List of vertices to be converted
...@@ -154,6 +161,13 @@ template< typename MeshT > ...@@ -154,6 +161,13 @@ template< typename MeshT >
inline inline
void convertVertexToFaceSelection(MeshT* _mesh, std::vector< int >& _vertices); void convertVertexToFaceSelection(MeshT* _mesh, std::vector< int >& _vertices);
/**
* For each selected vertex select all adjacent faces
*/
template< typename MeshT >
inline
void convertVertexToFaceSelection(MeshT* _mesh);
/** @} */ /** @} */
//=========================================================================== //===========================================================================
...@@ -246,6 +260,13 @@ template< typename MeshT > ...@@ -246,6 +260,13 @@ template< typename MeshT >
inline inline
void convertEdgeToVertexSelection(MeshT* _mesh, std::vector< int >& _edges); void convertEdgeToVertexSelection(MeshT* _mesh, std::vector< int >& _edges);
/**
* For each selected edge select all incident vertices
*/
template< typename MeshT >
inline
void convertEdgeToVertexSelection(MeshT* _mesh);
/** /**
* Select for each edge in _edges all adjacent faces * Select for each edge in _edges all adjacent faces
* @param _edges List of edges to be converted * @param _edges List of edges to be converted
...@@ -254,6 +275,12 @@ template< typename MeshT > ...@@ -254,6 +275,12 @@ template< typename MeshT >
inline inline
void convertEdgeToFaceSelection(MeshT* _mesh, std::vector< int >& _edges); void convertEdgeToFaceSelection(MeshT* _mesh, std::vector< int >& _edges);
/**
* For each selected edge select all adjacent faces
*/
template< typename MeshT >
inline
void convertEdgeToFaceSelection(MeshT* _mesh);
/** @} */ /** @} */
...@@ -329,12 +356,18 @@ inline ...@@ -329,12 +356,18 @@ inline
void convertFaceToVertexSelection(MeshT* _mesh, std::vector< int >& _faces); void convertFaceToVertexSelection(MeshT* _mesh, std::vector< int >& _faces);
/** /**
* Select for each face in _faces all adjacent edges * For each selected face select all adjacent vertices
* @param _faces List of faces to be converted */
template< typename MeshT >
inline
void convertFaceToVertexSelection(MeshT* _mesh);
/**
* For each selected face select all adjacent edges
*/ */
template< typename MeshT > template< typename MeshT >
inline inline
void convertFaceToEdgeSelection(MeshT* _mesh, std::vector< int >& _faces); void convertFaceToEdgeSelection(MeshT* _mesh);
/** @} */ /** @} */
//============================================================================= //=============================================================================
......
...@@ -1264,21 +1264,20 @@ void SelectionPlugin::convertVtoESelection(bool _unselectAfter) { ...@@ -1264,21 +1264,20 @@ void SelectionPlugin::convertVtoESelection(bool _unselectAfter) {
o_it != PluginFunctions::objectsEnd(); ++o_it) { o_it != PluginFunctions::objectsEnd(); ++o_it) {
#endif #endif
IdList list = getVertexSelection(o_it->id());
if(_unselectAfter) { clearVertexSelection(o_it->id()); }
if ( o_it->dataType() == DATA_TRIANGLE_MESH ) { if ( o_it->dataType() == DATA_TRIANGLE_MESH ) {
MeshSelection::convertVertexToEdgeSelection(PluginFunctions::triMesh(o_it), list); MeshSelection::convertVertexToEdgeSelection(PluginFunctions::triMesh(o_it));
} }
else if ( o_it->dataType() == DATA_POLY_MESH ) { else if ( o_it->dataType() == DATA_POLY_MESH ) {
MeshSelection::convertVertexToEdgeSelection(PluginFunctions::polyMesh(o_it), list); MeshSelection::convertVertexToEdgeSelection(PluginFunctions::polyMesh(o_it));
} }
#ifdef ENABLE_TSPLINEMESH_SUPPORT #ifdef ENABLE_TSPLINEMESH_SUPPORT
else if ( o_it->dataType() == DATA_TSPLINE_MESH ) { else if ( o_it->dataType() == DATA_TSPLINE_MESH ) {
MeshSelection::convertVertexToEdgeSelection(PluginFunctions::tsplineMesh(o_it), list); MeshSelection::convertVertexToEdgeSelection(PluginFunctions::tsplineMesh(o_it));
} }
#endif #endif
if(_unselectAfter) { clearVertexSelection(o_it->id()); }
o_it->update(); o_it->update();
} }
...@@ -1304,21 +1303,20 @@ void SelectionPlugin::convertVtoFSelection(bool _unselectAfter) { ...@@ -1304,21 +1303,20 @@ void SelectionPlugin::convertVtoFSelection(bool _unselectAfter) {
o_it != PluginFunctions::objectsEnd(); ++o_it) { o_it != PluginFunctions::objectsEnd(); ++o_it) {
#endif #endif
IdList list = getVertexSelection(o_it->id());
if(_unselectAfter) { clearVertexSelection(o_it->id()); }
if ( o_it->dataType() == DATA_TRIANGLE_MESH ) { if ( o_it->dataType() == DATA_TRIANGLE_MESH ) {
MeshSelection::convertVertexToFaceSelection(PluginFunctions::triMesh(o_it), list); MeshSelection::convertVertexToFaceSelection(PluginFunctions::triMesh(o_it));
} }
else if ( o_it->dataType() == DATA_POLY_MESH ) { else if ( o_it->dataType() == DATA_POLY_MESH ) {
MeshSelection::convertVertexToFaceSelection(PluginFunctions::polyMesh(o_it), list); MeshSelection::convertVertexToFaceSelection(PluginFunctions::polyMesh(o_it));
} }
#ifdef ENABLE_TSPLINEMESH_SUPPORT #ifdef ENABLE_TSPLINEMESH_SUPPORT
else if ( o_it->dataType() == DATA_TSPLINE_MESH ) { else if ( o_it->dataType() == DATA_TSPLINE_MESH ) {
MeshSelection::convertVertexToFaceSelection(PluginFunctions::tsplineMesh(o_it), list); MeshSelection::convertVertexToFaceSelection(PluginFunctions::tsplineMesh(o_it));
} }
#endif #endif
if(_unselectAfter) { clearVertexSelection(o_it->id()); }
o_it->update(); o_it->update();
} }
...@@ -1344,21 +1342,20 @@ void SelectionPlugin::convertEtoVSelection(bool _unselectAfter) { ...@@ -1344,21 +1342,20 @@ void SelectionPlugin::convertEtoVSelection(bool _unselectAfter) {
o_it != PluginFunctions::objectsEnd(); ++o_it) { o_it != PluginFunctions::objectsEnd(); ++o_it) {
#endif #endif
IdList list = getEdgeSelection(o_it->id());
if(_unselectAfter) { clearEdgeSelection(o_it->id()); }
if ( o_it->dataType() == DATA_TRIANGLE_MESH ) { if ( o_it->dataType() == DATA_TRIANGLE_MESH ) {
MeshSelection::convertEdgeToVertexSelection(PluginFunctions::triMesh(o_it), list); MeshSelection::convertEdgeToVertexSelection(PluginFunctions::triMesh(o_it));
} }
else if ( o_it->dataType() == DATA_POLY_MESH ) { else if ( o_it->dataType() == DATA_POLY_MESH ) {
MeshSelection::convertEdgeToVertexSelection(PluginFunctions::polyMesh(o_it), list); MeshSelection::convertEdgeToVertexSelection(PluginFunctions::polyMesh(o_it));
} }
#ifdef ENABLE_TSPLINEMESH_SUPPORT #ifdef ENABLE_TSPLINEMESH_SUPPORT
else if ( o_it->dataType() == DATA_TSPLINE_MESH ) { else if ( o_it->dataType() == DATA_TSPLINE_MESH ) {
MeshSelection::convertEdgeToVertexSelection(PluginFunctions::tsplineMesh(o_it), list); MeshSelection::convertEdgeToVertexSelection(PluginFunctions::tsplineMesh(o_it));
} }
#endif #endif
if(_unselectAfter) { clearEdgeSelection(o_it->id()); }
o_it->update(); o_it->update();
} }
...@@ -1384,21 +1381,20 @@ void SelectionPlugin::convertEtoFSelection(bool _unselectAfter) { ...@@ -1384,21 +1381,20 @@ void SelectionPlugin::convertEtoFSelection(bool _unselectAfter) {
o_it != PluginFunctions::objectsEnd(); ++o_it) { o_it != PluginFunctions::objectsEnd(); ++o_it) {
#endif #endif
IdList list = getEdgeSelection(o_it->id());
if(_unselectAfter) { clearEdgeSelection(o_it->id()); }
if ( o_it->dataType() == DATA_TRIANGLE_MESH ) { if ( o_it->dataType() == DATA_TRIANGLE_MESH ) {
MeshSelection::convertEdgeToFaceSelection(PluginFunctions::triMesh(o_it), list); MeshSelection::convertEdgeToFaceSelection(PluginFunctions::triMesh(o_it));
} }
else if ( o_it->dataType() == DATA_POLY_MESH ) { else if ( o_it->dataType() == DATA_POLY_MESH ) {
MeshSelection::convertEdgeToFaceSelection(PluginFunctions::polyMesh(o_it), list); MeshSelection::convertEdgeToFaceSelection(PluginFunctions::polyMesh(o_it));
} }
#ifdef ENABLE_TSPLINEMESH_SUPPORT #ifdef ENABLE_TSPLINEMESH_SUPPORT
else if ( o_it->dataType() == DATA_TSPLINE_MESH ) { else if ( o_it->dataType() == DATA_TSPLINE_MESH ) {
MeshSelection::convertEdgeToFaceSelection(PluginFunctions::tsplineMesh(o_it), list); MeshSelection::convertEdgeToFaceSelection(PluginFunctions::tsplineMesh(o_it));
} }
#endif #endif
if(_unselectAfter) { clearEdgeSelection(o_it->id()); }
o_it->update(); o_it->update();
} }
...@@ -1424,21 +1420,20 @@ void SelectionPlugin::convertFtoVSelection(bool _unselectAfter) { ...@@ -1424,21 +1420,20 @@ void SelectionPlugin::convertFtoVSelection(bool _unselectAfter) {
o_it != PluginFunctions::objectsEnd(); ++o_it) { o_it != PluginFunctions::objectsEnd(); ++o_it) {
#endif #endif
IdList list = getFaceSelection(o_it->id());
if(_unselectAfter) { clearFaceSelection(o_it->id()); }
if ( o_it->dataType() == DATA_TRIANGLE_MESH ) { if ( o_it->dataType() == DATA_TRIANGLE_MESH ) {
MeshSelection::convertFaceToVertexSelection(PluginFunctions::triMesh(o_it), list); MeshSelection::convertFaceToVertexSelection(PluginFunctions::triMesh(o_it));
} }
else if ( o_it->dataType() == DATA_POLY_MESH ) { else if ( o_it->dataType() == DATA_POLY_MESH ) {
MeshSelection::convertFaceToVertexSelection(PluginFunctions::polyMesh(o_it), list); MeshSelection::convertFaceToVertexSelection(PluginFunctions::polyMesh(o_it));
} }
#ifdef ENABLE_TSPLINEMESH_SUPPORT #ifdef ENABLE_TSPLINEMESH_SUPPORT
else if ( o_it->dataType() == DATA_TSPLINE_MESH ) { else if ( o_it->dataType() == DATA_TSPLINE_MESH ) {
MeshSelection::convertFaceToVertexSelection(PluginFunctions::tsplineMesh(o_it), list); MeshSelection::convertFaceToVertexSelection(PluginFunctions::tsplineMesh(o_it));
} }
#endif #endif
if(_unselectAfter) { clearFaceSelection(o_it->id()); }
o_it->update(); o_it->update();
} }
...@@ -1464,21 +1459,20 @@ void SelectionPlugin::convertFtoESelection(bool _unselectAfter) { ...@@ -1464,21 +1459,20 @@ void SelectionPlugin::convertFtoESelection(bool _unselectAfter) {
o_it != PluginFunctions::objectsEnd(); ++o_it) { o_it != PluginFunctions::objectsEnd(); ++o_it) {
#endif #endif
IdList list = getFaceSelection(o_it->id());
if(_unselectAfter) { clearFaceSelection(o_it->id()); }
if ( o_it->dataType() == DATA_TRIANGLE_MESH ) { if ( o_it->dataType() == DATA_TRIANGLE_MESH ) {
MeshSelection::convertFaceToEdgeSelection(PluginFunctions::triMesh(o_it), list); MeshSelection::convertFaceToEdgeSelection(PluginFunctions::triMesh(o_it));
} }
else if ( o_it->dataType() == DATA_POLY_MESH ) { else if ( o_it->dataType() == DATA_POLY_MESH ) {
MeshSelection::convertFaceToEdgeSelection(PluginFunctions::polyMesh(o_it), list); MeshSelection::convertFaceToEdgeSelection(PluginFunctions::polyMesh(o_it));
} }
#ifdef ENABLE_TSPLINEMESH_SUPPORT #ifdef ENABLE_TSPLINEMESH_SUPPORT
else if ( o_it->dataType() == DATA_TSPLINE_MESH ) { else if ( o_it->dataType() == DATA_TSPLINE_MESH ) {
MeshSelection::convertFaceToEdgeSelection(PluginFunctions::tsplineMesh(o_it), list); MeshSelection::convertFaceToEdgeSelection(PluginFunctions::tsplineMesh(o_it));
} }
#endif #endif
if(_unselectAfter) { clearFaceSelection(o_it->id()); }
o_it->update(); o_it->update();
} }
......
Supports Markdown
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