53 #define MESHSELECTION_C 58 #include <OpenMesh/Core/Mesh/TriMesh_ArrayKernelT.hh> 72 template<
typename MeshT >
75 const int n_vertices = (int)_mesh->n_vertices();
77 for ( uint i = 0 ; i < _vertices.size() ; ++i )
78 if ( (_vertices[i] >= 0) && ( _vertices[i] < n_vertices ) ) {
79 typename MeshT::VertexHandle vh(_vertices[i]);
80 _mesh->status(vh).set_selected(
true);
86 template<
typename MeshT >
89 const int n_vertices = (int)_mesh->n_vertices();
91 for ( uint i = 0 ; i < _vertices.size() ; ++i )
92 if ( (_vertices[i] >= 0) && ( _vertices[i] < n_vertices ) ) {
93 typename MeshT::VertexHandle vh(_vertices[i]);
94 _mesh->status(vh).set_selected(
false);
100 template<
typename MeshT >
103 typename MeshT::VertexIter v_it, v_end=_mesh->vertices_end();
105 for (v_it = _mesh->vertices_begin(); v_it != v_end ; ++v_it)
106 _mesh->status(*v_it).set_selected(
true);
112 template<
typename MeshT >
115 typename MeshT::VertexIter v_it, v_end=_mesh->vertices_end();
117 for (v_it = _mesh->vertices_begin(); v_it != v_end ; ++v_it)
118 _mesh->status(*v_it).set_selected(
false);
123 template<
typename MeshT >
126 typename MeshT::VertexIter v_it, v_end=_mesh->vertices_end();
128 for (v_it = _mesh->vertices_begin(); v_it != v_end ; ++v_it)
129 _mesh->status(*v_it).set_selected( ! _mesh->status(*v_it).selected());
135 template<
typename MeshT >
138 typename MeshT::HalfedgeIter he_it, he_end=_mesh->halfedges_end();
140 for (he_it = _mesh->halfedges_begin(); he_it != he_end ; ++he_it)
141 if (_mesh->is_boundary(*he_it) ) {
142 _mesh->status(_mesh->to_vertex_handle(*he_it)).set_selected(
true);
143 _mesh->status(_mesh->from_vertex_handle(*he_it)).set_selected(
true);
149 template<
typename MeshT >
154 _mesh->add_property( temp_shrink,
"Temp property for Vertex selection shrinking" );
156 typename MeshT::VertexIter v_it, v_end=_mesh->vertices_end();
159 for (v_it = _mesh->vertices_begin(); v_it != v_end ; ++v_it)
160 _mesh->property(temp_shrink,*v_it) = _mesh->status(*v_it).selected();
163 for (v_it = _mesh->vertices_begin(); v_it != v_end ; ++v_it)
164 if ( _mesh->property(temp_shrink,*v_it) ) {
165 _mesh->status(*v_it).set_selected(
true );
167 for (
typename MeshT::VertexVertexIter vv_it(*_mesh,*v_it); vv_it.is_valid(); ++vv_it)
168 if ( ! _mesh->property(temp_shrink,*vv_it) ){
169 _mesh->status(*v_it).set_selected(
false );
174 _mesh->remove_property(temp_shrink);
179 template<
typename MeshT >
184 _mesh->add_property( temp_grow,
"Temp property for Vertex selection growing" );
187 typename MeshT::VertexIter v_it, v_end=_mesh->vertices_end();
188 for (v_it = _mesh->vertices_begin(); v_it != v_end ; ++v_it)
189 _mesh->property(temp_grow,*v_it) = _mesh->status(*v_it).selected();
192 for (v_it = _mesh->vertices_begin(); v_it != v_end ; ++v_it)
193 if ( _mesh->property(temp_grow,*v_it) )
194 for (
typename MeshT::VertexVertexIter vv_it(*_mesh,*v_it); vv_it.is_valid(); ++vv_it)
195 _mesh->status(*vv_it).set_selected(
true );
197 _mesh->remove_property(temp_grow);
202 template<
typename MeshT >
205 std::vector< int > selection;
207 for (
typename MeshT::VertexIter v_it= _mesh->vertices_begin() ; v_it != _mesh->vertices_end() ; ++v_it )
208 if ( _mesh->status(*v_it).selected() )
209 selection.push_back( v_it->idx() );
216 template<
typename MeshT >
219 std::vector< int > selection;
223 for (
typename MeshT::VertexIter v_it= _mesh->vertices_begin() ; v_it != _mesh->vertices_end() ; ++v_it )
224 if ( _mesh->status(*v_it).selected() )
227 if ( count > (
int)( _mesh->n_vertices() / 2) )
232 for (
typename MeshT::VertexIter v_it= _mesh->vertices_begin() ; v_it != _mesh->vertices_end() ; ++v_it )
233 if ( _mesh->status(*v_it).selected() ^ _invert )
234 selection.push_back( v_it->idx() );
240 template<
typename MeshT >
245 _mesh->add_property(visited,
"Visited Vertices");
247 typename MeshT::VertexIter v_it, v_end = _mesh->vertices_end();
248 for (v_it = _mesh->vertices_begin(); v_it != v_end; ++v_it)
249 _mesh->property(visited, *v_it) =
false;
251 std::stack< typename MeshT::VertexHandle > stack;
254 while (!stack.empty()){
256 typename MeshT::VertexHandle vh = stack.top();
259 if (_mesh->property(visited,vh))
263 for (
typename MeshT::VertexOHalfedgeIter voh_it(*_mesh,vh); voh_it.is_valid(); ++voh_it)
264 if ( _mesh->is_boundary( _mesh->edge_handle( *voh_it ) ) )
265 stack.push( _mesh->to_vertex_handle(*voh_it) );
268 _mesh->property(visited,vh) =
true;
269 _mesh->status( vh ).set_selected(
true);
271 _mesh->remove_property(visited);
274 template<
typename MeshT >
278 for ( std::vector<int>::const_iterator v = _vertices.begin(); v != _vertices.end(); ++v) {
280 typename MeshT::VertexHandle vh(*v);
281 typename MeshT::VertexOHalfedgeIter ohe_iter = _mesh->voh_iter(vh);
283 for (; ohe_iter.is_valid(); ++ohe_iter) {
285 typename MeshT::VertexHandle ovh = _mesh->to_vertex_handle(*ohe_iter);
287 for(std::vector<int>::const_iterator it = _vertices.begin(); it != _vertices.end(); ++it) {
288 if((*it) == ovh.idx()) {
289 _mesh->status(_mesh->edge_handle(*ohe_iter)).set_selected(
true);
297 template<
typename MeshT >
301 typename MeshT::VertexIter v_it, v_end = _mesh->vertices_end();
302 for (v_it = _mesh->vertices_begin(); v_it != v_end; ++v_it) {
304 if ( _mesh->status( *v_it ).selected() ) {
305 typename MeshT::VertexOHalfedgeIter ohe_iter = _mesh->voh_iter(*v_it);
307 for (; ohe_iter.is_valid(); ++ohe_iter) {
309 typename MeshT::VertexHandle ovh = _mesh->to_vertex_handle(*ohe_iter);
310 if (_mesh->status(ovh).selected())
311 _mesh->status(_mesh->edge_handle(*ohe_iter)).set_selected(
true);
317 template<
typename MeshT >
321 for (std::vector<int>::const_iterator v = _vertices.begin(); v != _vertices.end(); ++v) {
323 typename MeshT::VertexHandle vh(*v);
324 typename MeshT::VertexOHalfedgeIter ohe_iter = _mesh->voh_iter(vh);
326 for (; ohe_iter.is_valid(); ++ohe_iter) {
328 typename MeshT::VertexHandle ovh = _mesh->to_vertex_handle(*ohe_iter);
330 for(std::vector<int>::const_iterator it = _vertices.begin(); it != _vertices.end(); ++it) {
331 if((*it) == ovh.idx()) {
332 _mesh->status(*ohe_iter).set_selected(
true);
333 _mesh->status(_mesh->opposite_halfedge_handle(*ohe_iter)).set_selected(
true);
341 template<
typename MeshT >
345 typename MeshT::VertexIter v_it, v_end = _mesh->vertices_end();
347 for (v_it = _mesh->vertices_begin(); v_it != v_end; ++v_it) {
349 if ( _mesh->status( *v_it ).selected() ) {
351 typename MeshT::VertexOHalfedgeIter ohe_iter = _mesh->voh_iter(*v_it);
353 for (; ohe_iter.is_valid(); ++ohe_iter) {
355 typename MeshT::VertexHandle ovh = _mesh->to_vertex_handle(*ohe_iter);
356 if (_mesh->status(ovh).selected()) {
357 _mesh->status(*ohe_iter).set_selected(
true);
358 _mesh->status(_mesh->opposite_halfedge_handle(*ohe_iter)).set_selected(
true);
365 template<
typename MeshT >
369 for(
typename MeshT::FaceIter f_it = _mesh->faces_begin(); f_it != _mesh->faces_end(); ++f_it) {
370 typename MeshT::FaceVertexIter fv_it = _mesh->fv_iter(*f_it);
372 bool allfound =
true;
373 for(; fv_it.is_valid(); ++fv_it) {
375 bool onefound =
false;
376 for(std::vector<int>::const_iterator it = _vertices.begin(); it != _vertices.end(); ++it) {
377 if((*it) == fv_it->idx()) { onefound =
true;
break; }
386 _mesh->status(*f_it).set_selected(
true);
391 template<
typename MeshT >
395 typename MeshT::FaceIter f_it, f_end = _mesh->faces_end();
397 for (f_it = _mesh->faces_begin(); f_it != f_end; ++f_it) {
399 typename MeshT::FaceVertexIter fv_it = _mesh->fv_iter(*f_it);
401 bool allfound =
true;
402 for(; fv_it.is_valid(); ++fv_it) {
403 if(!_mesh->status(*fv_it).selected()) {
409 _mesh->status(*f_it).set_selected(
true);
413 template<
typename MeshT >
417 for (
typename MeshT::VertexIter v_it = _mesh->vertices_begin(); v_it != _mesh->vertices_end(); ++v_it) {
419 if (_mesh->status(*v_it).selected()) {
421 _mesh->status(*v_it).set_feature(
true);
423 _mesh->status(*v_it).set_feature(
false);
428 template<
typename MeshT >
432 for (
typename MeshT::VertexIter v_it = _mesh->vertices_begin(); v_it != _mesh->vertices_end(); ++v_it) {
434 if (_mesh->status(*v_it).feature()) {
436 _mesh->status(*v_it).set_selected(
true);
438 _mesh->status(*v_it).set_selected(
false);
443 template<
typename MeshT >
447 for (
typename MeshT::VertexIter v_it = _mesh->vertices_begin(); v_it != _mesh->vertices_end(); ++v_it) {
449 _mesh->status(*v_it).set_feature(
false);
457 template<
typename MeshT >
459 void setArea(MeshT* _mesh,
const std::vector< int >& _vertices ,
unsigned int _type,
bool _state) {
460 for ( uint i = 0 ; i < _vertices.size() ; ++i ) {
461 if ( _vertices[i] > (
int)_mesh->n_vertices() )
464 typename MeshT::VertexHandle vh(_vertices[i]);
465 _mesh->status(vh).change_bit(_type, _state);
469 template<
typename MeshT >
471 void setArea(MeshT* _mesh ,
unsigned int _type,
bool _state) {
472 for (
typename MeshT::VertexIter v_it= _mesh->vertices_begin() ; v_it != _mesh->vertices_end() ; ++v_it )
473 _mesh->status(*v_it).change_bit(_type, _state);
476 template<
typename MeshT >
478 std::vector< int >
getArea(MeshT* _mesh,
unsigned int _type) {
479 std::vector< int > selection;
481 for (
typename MeshT::VertexIter v_it= _mesh->vertices_begin() ; v_it != _mesh->vertices_end() ; ++v_it )
482 if ( _mesh->status(*v_it).is_bit_set( _type ) )
483 selection.push_back( v_it->idx() );
488 template<
typename MeshT >
490 std::vector< int >
getArea(MeshT* _mesh,
unsigned int _type ,
bool& _invert) {
491 std::vector< int > selection;
495 for (
typename MeshT::VertexIter v_it= _mesh->vertices_begin() ; v_it != _mesh->vertices_end() ; ++v_it )
496 if ( _mesh->status(*v_it).is_bit_set( _type ) )
499 if ( count > (
int)( _mesh->n_vertices() / 2) )
504 for (
typename MeshT::VertexIter v_it= _mesh->vertices_begin() ; v_it != _mesh->vertices_end() ; ++v_it )
505 if ( _mesh->status(*v_it).is_bit_set( _type ) ^ _invert )
506 selection.push_back( v_it->idx() );
516 template<
typename MeshT >
518 void selectEdges(MeshT* _mesh,
const std::vector< int >& _edges,
const double _dihedral_angle_threshold) {
519 const int n_edges = (int)_mesh->n_edges();
521 for ( uint i = 0 ; i < _edges.size() ; ++i )
522 if ( (_edges[i] >= 0) && ( _edges[i] < n_edges ) ) {
523 typename MeshT::EdgeHandle eh(_edges[i]);
524 if(!_mesh->has_face_normals() || std::abs(_mesh->calc_dihedral_angle_fast(eh)) >= _dihedral_angle_threshold)
525 _mesh->status(eh).set_selected(
true);
531 template<
typename MeshT >
534 const int n_edges = (int)_mesh->n_edges();
536 for ( uint i = 0 ; i < _edges.size() ; ++i )
537 if ( (_edges[i] >= 0) && ( _edges[i] < n_edges ) ) {
538 typename MeshT::EdgeHandle eh(_edges[i]);
539 _mesh->status(eh).set_selected(
false);
545 template<
typename MeshT >
548 typename MeshT::EdgeIter e_it, e_end=_mesh->edges_end();
550 for (e_it = _mesh->edges_begin(); e_it != e_end ; ++e_it)
551 _mesh->status(*e_it).set_selected(
true);
556 template<
typename MeshT >
559 typename MeshT::EdgeIter e_it, e_end=_mesh->edges_end();
561 for (e_it = _mesh->edges_begin(); e_it != e_end ; ++e_it)
562 _mesh->status(*e_it).set_selected(
false);
567 template<
typename MeshT >
570 typename MeshT::EdgeIter e_it, e_end=_mesh->edges_end();
572 for (e_it = _mesh->edges_begin(); e_it != e_end ; ++e_it)
573 _mesh->status(*e_it).set_selected( ! _mesh->status(*e_it).selected());
578 template<
typename MeshT>
581 std::set<typename MeshT::EdgeHandle> selectedEhs;
582 for (
typename MeshT::EdgeIter e_it = _mesh->edges_begin(), e_end = _mesh->edges_end();
583 e_it != e_end; ++e_it) {
585 if (!_mesh->status(*e_it).selected())
continue;
587 const typename MeshT::HalfedgeHandle he = _mesh->halfedge_handle(*e_it, 0);
588 const typename MeshT::VertexHandle vhs[] = { _mesh->from_vertex_handle(he),
589 _mesh->to_vertex_handle(he) };
591 for (
int i = 0; i < 2; ++i) {
592 for (
typename MeshT::VertexEdgeIter ve_it = _mesh->ve_begin(vhs[i]), ve_end = _mesh->ve_end(vhs[i]);
593 ve_it != ve_end; ++ve_it) {
595 selectedEhs.insert(*ve_it);
601 for (
typename std::set<typename MeshT::EdgeHandle>::const_iterator it = selectedEhs.begin(); it != selectedEhs.end(); ++it)
602 _mesh->status(*it).set_selected(
true);
608 template<
typename MeshT >
611 typename MeshT::EdgeIter e_it, e_end=_mesh->edges_end();
613 for (e_it = _mesh->edges_begin(); e_it != e_end ; ++e_it)
614 if ( _mesh->is_boundary( _mesh->halfedge_handle(*e_it,0) ) ||
615 _mesh->is_boundary( _mesh->halfedge_handle(*e_it,1) ) )
616 _mesh->status(*e_it).set_selected(
true );
621 template<
typename MeshT >
624 std::vector< int > selection;
626 for (
typename MeshT::EdgeIter e_it= _mesh->edges_begin() ; e_it != _mesh->edges_end() ; ++e_it )
627 if ( _mesh->status(*e_it).selected() )
628 selection.push_back( e_it->idx() );
635 template<
typename MeshT >
638 std::vector< int > selection;
642 for (
typename MeshT::VertexIter e_it= _mesh->edges_begin() ; e_it != _mesh->edges_end() ; ++e_it )
643 if ( _mesh->status(*e_it).selected() )
646 if ( count > (
int)( _mesh->n_vertices() / 2) )
651 for (
typename MeshT::VertexIter e_it= _mesh->edges_begin() ; e_it != _mesh->edges_end() ; ++e_it )
652 if ( _mesh->status(*e_it).selected() ^ _invert )
653 selection.push_back( e_it->idx() );
658 template<
typename MeshT >
662 for (std::vector<int>::const_iterator e = _edges.begin(); e != _edges.end(); ++e) {
664 typename MeshT::EdgeHandle eh(*e);
665 typename MeshT::HalfedgeHandle heh0 = _mesh->halfedge_handle(eh, 0);
667 typename MeshT::VertexHandle vh0 = _mesh->to_vertex_handle(heh0);
668 typename MeshT::VertexHandle vh1 = _mesh->from_vertex_handle(heh0);
670 _mesh->status(vh0).set_selected(
true);
671 _mesh->status(vh1).set_selected(
true);
675 template<
typename MeshT >
679 for (
typename MeshT::EdgeIter e_it= _mesh->edges_begin() ; e_it != _mesh->edges_end() ; ++e_it )
681 if ( _mesh->status(*e_it).selected() ){
683 typename MeshT::HalfedgeHandle heh0 = _mesh->halfedge_handle(*e_it, 0);
685 typename MeshT::VertexHandle vh0 = _mesh->to_vertex_handle(heh0);
686 typename MeshT::VertexHandle vh1 = _mesh->from_vertex_handle(heh0);
688 _mesh->status(vh0).set_selected(
true);
689 _mesh->status(vh1).set_selected(
true);
693 template<
typename MeshT >
697 for(
typename MeshT::FaceIter f_it = _mesh->faces_begin(); f_it != _mesh->faces_end(); ++f_it) {
698 typename MeshT::FaceEdgeIter fe_it = _mesh->fe_iter(*f_it);
700 bool allfound =
true;
701 for(; fe_it.is_valid(); ++fe_it) {
703 bool onefound =
false;
704 for(std::vector<int>::const_iterator it = _edges.begin(); it != _edges.end(); ++it) {
705 if((*it) == fe_it->idx()) { onefound =
true;
break; }
714 _mesh->status(*f_it).set_selected(
true);
719 template<
typename MeshT >
723 typename MeshT::FaceIter f_it, f_end = _mesh->faces_end();
725 for (f_it = _mesh->faces_begin(); f_it != f_end; ++f_it) {
727 typename MeshT::FaceEdgeIter fe_it = _mesh->fe_iter(*f_it);
729 bool allfound =
true;
730 for(; fe_it.is_valid(); ++fe_it) {
731 if(!_mesh->status(*fe_it).selected()) {
737 _mesh->status(*f_it).set_selected(
true);
741 template<
typename MeshT >
745 for (
typename MeshT::EdgeIter e_it= _mesh->edges_begin() ; e_it != _mesh->edges_end() ; ++e_it )
747 if ( _mesh->status(*e_it).selected() ){
749 _mesh->status(_mesh->halfedge_handle(*e_it, 0)).set_selected(
true);
750 _mesh->status(_mesh->halfedge_handle(*e_it, 1)).set_selected(
true);
754 template<
typename MeshT >
758 for (
typename MeshT::EdgeIter e_it = _mesh->edges_begin(); e_it != _mesh->edges_end(); ++e_it) {
760 if (_mesh->status(*e_it).selected()) {
762 _mesh->status(*e_it).set_feature(
true);
764 _mesh->status(*e_it).set_feature(
false);
769 template<
typename MeshT >
773 for (
typename MeshT::EdgeIter e_it = _mesh->edges_begin(); e_it != _mesh->edges_end(); ++e_it) {
775 if (_mesh->status(*e_it).feature()) {
777 _mesh->status(*e_it).set_selected(
true);
779 _mesh->status(*e_it).set_selected(
false);
784 template<
typename MeshT >
788 for (
typename MeshT::EdgeIter e_it = _mesh->edges_begin(); e_it != _mesh->edges_end(); ++e_it) {
790 _mesh->status(*e_it).set_feature(
false);
798 template<
typename MeshT >
801 const int n_halfedges = (int)_mesh->n_halfedges();
803 for ( uint i = 0 ; i < _halfedges.size() ; ++i )
804 if ( (_halfedges[i] >= 0) && ( _halfedges[i] < n_halfedges ) ) {
805 typename MeshT::HalfedgeHandle heh(_halfedges[i]);
806 _mesh->status(heh).set_selected(
true);
812 template<
typename MeshT >
815 const int n_halfedges = (int)_mesh->n_halfedges();
817 for ( uint i = 0 ; i < _halfedges.size() ; ++i )
818 if ( (_halfedges[i] >= 0) && ( _halfedges[i] < n_halfedges ) ) {
819 typename MeshT::HalfedgeHandle heh(_halfedges[i]);
820 _mesh->status(heh).set_selected(
false);
826 template<
typename MeshT >
829 typename MeshT::HalfedgeIter he_it, he_end=_mesh->halfedges_end();
831 for (he_it = _mesh->halfedges_begin(); he_it != he_end ; ++he_it)
832 _mesh->status(*he_it).set_selected(
true);
837 template<
typename MeshT >
840 typename MeshT::HalfedgeIter he_it, he_end=_mesh->halfedges_end();
842 for (he_it = _mesh->halfedges_begin(); he_it != he_end ; ++he_it)
843 _mesh->status(*he_it).set_selected(
false);
848 template<
typename MeshT >
851 typename MeshT::HalfedgeIter he_it, he_end=_mesh->halfedges_end();
853 for (he_it = _mesh->halfedges_begin(); he_it != he_end ; ++he_it)
854 _mesh->status(*he_it).set_selected( ! _mesh->status(*he_it).selected());
860 template<
typename MeshT >
863 typename MeshT::HalfedgeIter he_it, he_end=_mesh->halfedges_end();
865 for (he_it = _mesh->halfedges_begin(); he_it != he_end ; ++he_it)
866 if ( _mesh->is_boundary( *he_it))
867 _mesh->status(*he_it).set_selected(
true );
872 template<
typename MeshT >
875 std::vector< int > selection;
877 for (
typename MeshT::HalfedgeIter he_it= _mesh->halfedges_begin() ; he_it != _mesh->halfedges_end() ; ++he_it )
878 if ( _mesh->status(*he_it).selected() )
879 selection.push_back( he_it->idx() );
884 template<
typename MeshT >
888 for (
typename MeshT::HalfedgeIter he_it= _mesh->halfedges_begin() ; he_it != _mesh->halfedges_end() ; ++he_it ) {
890 if(_mesh->status(*he_it).selected()) {
891 _mesh->status(_mesh->to_vertex_handle(*he_it)).set_selected(
true);
892 _mesh->status(_mesh->from_vertex_handle(*he_it)).set_selected(
true);
897 template<
typename MeshT >
901 for (
typename MeshT::HalfedgeIter he_it= _mesh->halfedges_begin() ; he_it != _mesh->halfedges_end() ; ++he_it ) {
903 if(_mesh->status(*he_it).selected()) {
904 _mesh->status(_mesh->edge_handle(*he_it)).set_selected(
true);
909 template<
typename MeshT >
916 for (
typename MeshT::HalfedgeIter he_it= _mesh->halfedges_begin() ; he_it != _mesh->halfedges_end() ; ++he_it ) {
918 if(_mesh->status(*he_it).selected()) {
919 _mesh->status(_mesh->face_handle(*he_it)).set_selected(
true);
928 template<
typename MeshT >
930 void selectFaces(MeshT* _mesh,
const std::vector< int >& _faces) {
931 const int n_faces = (int)_mesh->n_faces();
933 for ( uint i = 0 ; i < _faces.size() ; ++i )
934 if ( (_faces[i] >= 0) && ( _faces[i] < n_faces ) ) {
935 typename MeshT::FaceHandle fh(_faces[i]);
936 _mesh->status(fh).set_selected(
true);
942 template<
typename MeshT >
945 const int n_faces = (int)_mesh->n_faces();
947 for ( uint i = 0 ; i < _faces.size() ; ++i )
948 if ( (_faces[i] >= 0) && ( _faces[i] < n_faces ) ) {
949 typename MeshT::FaceHandle fh(_faces[i]);
950 _mesh->status(fh).set_selected(
false);
956 template<
typename MeshT >
959 typename MeshT::FaceIter f_it, f_end=_mesh->faces_end();
961 for (f_it = _mesh->faces_begin(); f_it != f_end ; ++f_it)
962 _mesh->status(*f_it).set_selected(
true);
968 template<
typename MeshT >
971 typename MeshT::FaceIter f_it, f_end=_mesh->faces_end();
973 for (f_it = _mesh->faces_begin(); f_it != f_end ; ++f_it)
974 _mesh->status(*f_it).set_selected(
false);
980 template<
typename MeshT >
983 typename MeshT::FaceIter f_it, f_end=_mesh->faces_end();
985 for (f_it = _mesh->faces_begin(); f_it != f_end ; ++f_it)
986 _mesh->status(*f_it).set_selected( ! _mesh->status(*f_it).selected());
991 template<
typename MeshT >
994 typename MeshT::HalfedgeIter he_it, he_end=_mesh->halfedges_end();
996 for (he_it = _mesh->halfedges_begin(); he_it != he_end ; ++he_it)
997 if (_mesh->is_boundary(*he_it) ) {
998 for (
typename MeshT::VertexFaceIter vf_it(*_mesh ,_mesh->to_vertex_handle(*he_it) ) ; vf_it.is_valid() ; ++vf_it)
999 _mesh->status(*vf_it).set_selected(
true);
1000 for (
typename MeshT::VertexFaceIter vf_it(*_mesh ,_mesh->from_vertex_handle(*he_it) ) ; vf_it.is_valid() ; ++vf_it)
1001 _mesh->status(*vf_it).set_selected(
true);
1008 template<
typename MeshT >
1013 _mesh->add_property( temp_shrink,
"Temp property for Face selection shrinking" );
1015 typename MeshT::FaceIter f_it, f_end=_mesh->faces_end();
1018 for (f_it = _mesh->faces_begin(); f_it != f_end ; ++f_it)
1019 _mesh->property(temp_shrink,*f_it) = _mesh->status(*f_it).selected();
1022 for (f_it = _mesh->faces_begin(); f_it != f_end ; ++f_it)
1023 if ( _mesh->property(temp_shrink,*f_it) ) {
1024 bool boundary =
false;
1025 for (
typename MeshT::FaceVertexIter fv_it(*_mesh,*f_it); fv_it.is_valid() ; ++fv_it) {
1026 for (
typename MeshT::VertexFaceIter vf_it(*_mesh,*fv_it); vf_it.is_valid() ; ++vf_it) {
1027 if ( ! _mesh->property(temp_shrink,*vf_it) ) {
1035 _mesh->status(*f_it).set_selected( !boundary );
1038 _mesh->remove_property(temp_shrink);
1043 template<
typename MeshT >
1048 _mesh->add_property( temp_grow,
"Temp property for Face selection growing" );
1050 typename MeshT::FaceIter f_it, f_end=_mesh->faces_end();
1053 for (f_it = _mesh->faces_begin(); f_it != f_end ; ++f_it)
1054 _mesh->property(temp_grow,*f_it) = _mesh->status(*f_it).selected();
1057 for (f_it = _mesh->faces_begin(); f_it != f_end ; ++f_it)
1058 if ( _mesh->property(temp_grow,*f_it) )
1059 for (
typename MeshT::FaceVertexIter fv_it(*_mesh,*f_it); fv_it.is_valid() ; ++fv_it)
1060 for (
typename MeshT::VertexFaceIter vf_it(*_mesh,*fv_it); vf_it.is_valid() ; ++vf_it)
1061 _mesh->status(*vf_it).set_selected(
true );
1063 _mesh->remove_property(temp_grow);
1068 template<
typename MeshT >
1071 std::vector< int > selection;
1073 for (
typename MeshT::FaceIter f_it= _mesh->faces_begin() ; f_it != _mesh->faces_end() ; ++f_it )
1074 if ( _mesh->status(*f_it).selected() )
1075 selection.push_back( f_it->idx() );
1082 template<
typename MeshT >
1085 std::vector< int > selection;
1089 for (
typename MeshT::FaceIter f_it= _mesh->faces_begin() ; f_it != _mesh->faces_end() ; ++f_it )
1090 if ( _mesh->status(*f_it).selected() )
1093 if ( count > (
int)( _mesh->n_vertices() / 2) )
1098 for (
typename MeshT::FaceIter f_it= _mesh->faces_begin() ; f_it != _mesh->faces_end() ; ++f_it )
1099 if ( _mesh->status(*f_it).selected() ^ _invert )
1100 selection.push_back( f_it->idx() );
1105 template<
typename MeshT >
1109 for (std::vector<int>::const_iterator f = _faces.begin(); f != _faces.end(); ++f) {
1111 typename MeshT::FaceHandle fh(*f);
1113 typename MeshT::FaceVertexIter v_iter = _mesh->fv_iter(fh);
1115 for (; v_iter.is_valid(); ++v_iter) {
1116 _mesh->status(*v_iter).set_selected(
true);
1121 template<
typename MeshT >
1125 for (
typename MeshT::FaceIter f_it= _mesh->faces_begin() ; f_it != _mesh->faces_end() ; ++f_it )
1127 if ( _mesh->status(*f_it).selected() ){
1129 typename MeshT::FaceVertexIter v_iter = _mesh->fv_iter(*f_it);
1131 for (; v_iter.is_valid(); ++v_iter)
1132 _mesh->status(*v_iter).set_selected(
true);
1136 template<
typename MeshT >
1140 for (std::vector<int>::const_iterator f = _faces.begin(); f != _faces.end(); ++f) {
1142 typename MeshT::FaceHandle fh(*f);
1144 typename MeshT::FaceEdgeIter e_iter = _mesh->fe_iter(fh);
1146 for (; e_iter.is_valid(); ++e_iter) {
1147 _mesh->status(*e_iter).set_selected(
true);
1152 template<
typename MeshT >
1156 for (
typename MeshT::FaceIter f_it= _mesh->faces_begin() ; f_it != _mesh->faces_end() ; ++f_it )
1158 if ( _mesh->status(*f_it).selected() ){
1160 typename MeshT::FaceEdgeIter e_iter = _mesh->fe_iter(*f_it);
1162 for (; e_iter.is_valid(); ++e_iter)
1163 _mesh->status(*e_iter).set_selected(
true);
1167 template<
typename MeshT >
1171 for (
typename MeshT::FaceIter f_it= _mesh->faces_begin() ; f_it != _mesh->faces_end() ; ++f_it )
1173 if ( _mesh->status(*f_it).selected() ){
1175 typename MeshT::FaceHalfedgeIter fh_iter = _mesh->fh_iter(*f_it);
1177 for (; fh_iter.is_valid(); ++fh_iter)
1178 _mesh->status(*fh_iter).set_selected(
true);
1182 template<
typename MeshT >
1186 for (
typename MeshT::FaceIter f_it = _mesh->faces_begin(); f_it != _mesh->faces_end(); ++f_it) {
1188 if (_mesh->status(*f_it).selected()) {
1190 _mesh->status(*f_it).set_feature(
true);
1192 _mesh->status(*f_it).set_feature(
false);
1197 template<
typename MeshT >
1201 for (
typename MeshT::FaceIter f_it = _mesh->faces_begin(); f_it != _mesh->faces_end(); ++f_it) {
1203 if (_mesh->status(*f_it).feature()) {
1205 _mesh->status(*f_it).set_selected(
true);
1207 _mesh->status(*f_it).set_selected(
false);
1212 template<
typename MeshT >
1216 for (
typename MeshT::FaceIter f_it = _mesh->faces_begin(); f_it != _mesh->faces_end(); ++f_it) {
1218 _mesh->status(*f_it).set_feature(
false);
void selectFaces(MeshT *_mesh, const std::vector< int > &_faces)
Select given faces of a mesh.
void convertVertexSelectionToFeatureVertices(MeshT *_mesh)
Convert vertex selection to feature selection.
void convertHalfedgeToEdgeSelection(MeshT *_mesh)
void clearEdgeSelection(MeshT *_mesh)
Set all edges to unselected.
void setArea(MeshT *_mesh, const std::vector< int > &_vertices, unsigned int _type, bool _state)
Set the area bit for all defined vertices.
void shrinkFaceSelection(MeshT *_mesh)
Shrink Face selection.
void convertFeatureEdgesToEdgeSelection(MeshT *_mesh)
void unselectHalfedges(MeshT *_mesh, const std::vector< int > &_halfedges)
Unselect given edges of a mesh.
void invertEdgeSelection(MeshT *_mesh)
Invert Edge selection.
void convertFaceToEdgeSelection(MeshT *_mesh)
std::vector< int > getVertexSelection(MeshT *_mesh)
Get the current vertex selection.
void clearVertexSelection(MeshT *_mesh)
Set all vertices to unselected.
void convertFeatureFacesToFaceSelection(MeshT *_mesh)
void clearFaceSelection(MeshT *_mesh)
Set all faces to unselected.
void selectBoundaryFaces(MeshT *_mesh)
Select all boundary faces of a mesh.
void convertEdgeToVertexSelection(MeshT *_mesh, const std::vector< int > &_edges)
void invertVertexSelection(MeshT *_mesh)
invert vertex selection
void selectAllFaces(MeshT *_mesh)
Select all faces of a mesh.
void selectEdges(MeshT *_mesh, const std::vector< int > &_edges, const double _dihedral_angle_threshold=0.0)
Select given edges of a mesh.
void clearFeatureVertices(MeshT *_mesh)
Clear all features.
void convertFaceToVertexSelection(MeshT *_mesh, const std::vector< int > &_faces)
void shrinkVertexSelection(MeshT *_mesh)
Shrink vertex selection.
void unselectFaces(MeshT *_mesh, const std::vector< int > &_faces)
Unselect given faces of a mesh.
void convertHalfedgeToFaceSelection(MeshT *_mesh)
void convertVertexToHalfedgeSelection(MeshT *_mesh, const std::vector< int > &_vertices)
Select for each vertex in _vertices all incident halfedges.
void convertEdgeToHalfedgeSelection(MeshT *_mesh)
void clearFeatureFaces(MeshT *_mesh)
std::vector< int > getHalfedgeSelection(MeshT *_mesh)
void invertHalfedgeSelection(MeshT *_mesh)
Invert Edge selection.
void selectHalfedges(MeshT *_mesh, const std::vector< int > &_halfedges)
Select given halfedges of a mesh.
void convertEdgeToFaceSelection(MeshT *_mesh, const std::vector< int > &_edges)
void selectAllHalfedges(MeshT *_mesh)
Select all edges of a mesh.
Functions for selection on a mesh.
void convertHalfedgeToVertexSelection(MeshT *_mesh)
void convertFaceSelectionToFeatureFaces(MeshT *_mesh)
void unselectEdges(MeshT *_mesh, const std::vector< int > &_edges)
Unselect given edges of a mesh.
std::vector< int > getEdgeSelection(MeshT *_mesh)
void convertFaceToHalfedgeSelection(MeshT *_mesh)
void unselectVertices(MeshT *_mesh, const std::vector< int > &_vertices)
Unselect given vertices of a mesh.
std::vector< int > getArea(MeshT *_mesh, unsigned int _type)
void growFaceSelection(MeshT *_mesh)
Grow Face selection.
void convertFeatureVerticesToVertexSelection(MeshT *_mesh)
Convert feature selection to vertex selection.
void invertFaceSelection(MeshT *_mesh)
Invert face selection.
void growVertexSelection(MeshT *_mesh)
Grow vertex selection.
void clearHalfedgeSelection(MeshT *_mesh)
Set all edges to unselected.
void convertVertexToEdgeSelection(MeshT *_mesh, const std::vector< int > &_vertices)
Select for each vertex in _vertices all incident edges.
void selectAllEdges(MeshT *_mesh)
Select all edges of a mesh.
void convertEdgeSelectionToFeatureEdges(MeshT *_mesh)
void selectBoundaryEdges(MeshT *_mesh)
Select all boundary edges of a mesh.
void selectBoundaryVertices(MeshT *_mesh)
Select all vertices of the mesh which are boundary vertices.
std::vector< int > getFaceSelection(MeshT *_mesh)
void convertVertexToFaceSelection(MeshT *_mesh, const std::vector< int > &_vertices)
Select for each vertex in _vertices all adjacent faces.
void growEdgeSelection(MeshT *_mesh)
Invert Edge selection.
void clearFeatureEdges(MeshT *_mesh)
void selectAllVertices(MeshT *_mesh)
Select all vertices of a mesh.
void selectBoundaryHalfedges(MeshT *_mesh)
Select all boundary edges of a mesh.
void selectVertices(MeshT *_mesh, const std::vector< int > &_vertices)
Select given vertices of a mesh.