StatusNodeMods.hh

00001 /*===========================================================================*\
00002  *                                                                           *
00003  *                              OpenFlipper                                  *
00004  *      Copyright (C) 2001-2009 by Computer Graphics Group, RWTH Aachen      *
00005  *                           www.openflipper.org                             *
00006  *                                                                           *
00007  *---------------------------------------------------------------------------*
00008  *  This file is part of OpenFlipper.                                        *
00009  *                                                                           *
00010  *  OpenFlipper is free software: you can redistribute it and/or modify      *
00011  *  it under the terms of the GNU Lesser General Public License as           *
00012  *  published by the Free Software Foundation, either version 3 of           *
00013  *  the License, or (at your option) any later version with the              *
00014  *  following exceptions:                                                    *
00015  *                                                                           *
00016  *  If other files instantiate templates or use macros                       *
00017  *  or inline functions from this file, or you compile this file and         *
00018  *  link it with other files to produce an executable, this file does        *
00019  *  not by itself cause the resulting executable to be covered by the        *
00020  *  GNU Lesser General Public License. This exception does not however       *
00021  *  invalidate any other reasons why the executable file might be            *
00022  *  covered by the GNU Lesser General Public License.                        *
00023  *                                                                           *
00024  *  OpenFlipper is distributed in the hope that it will be useful,           *
00025  *  but WITHOUT ANY WARRANTY; without even the implied warranty of           *
00026  *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the            *
00027  *  GNU Lesser General Public License for more details.                      *
00028  *                                                                           *
00029  *  You should have received a copy of the GNU LesserGeneral Public          *
00030  *  License along with OpenFlipper. If not,                                  *
00031  *  see <http://www.gnu.org/licenses/>.                                      *
00032  *                                                                           *
00033 \*===========================================================================*/
00034 
00035 /*===========================================================================*\
00036  *                                                                           *
00037  *   $Revision: 6726 $                                                         *
00038  *   $Author: moebius $                                                      *
00039  *   $Date: 2009-08-05 07:47:19 +0200 (Mi, 05. Aug 2009) $                   *
00040  *                                                                           *
00041 \*===========================================================================*/
00042 
00043 
00044 
00045 
00046 
00047 //=============================================================================
00048 //
00049 //  Mods for the Status Nodes
00050 //
00051 //=============================================================================
00052 
00055 template< class MeshT >
00056 struct AreaNodeMod
00057 {
00059   static inline bool is_area(const MeshT& _m, typename MeshT::VertexHandle _vh)
00060   { return _m.status(_vh).is_bit_set(AREA); }
00061 
00063   static inline bool is_area(const MeshT& _m, typename MeshT::FaceHandle _fh)
00064   { return _m.status(_fh).is_bit_set(AREA); }
00065 
00067   static bool is_vertex_selected(const MeshT& _mesh, typename MeshT::VertexHandle _vh)
00068   {
00069     if (_mesh.is_isolated(_vh))
00070       return is_area(_mesh, _vh);
00071     else
00072       return false;
00073   }
00074 
00075 
00077   static bool is_edge_selected(const MeshT& /*_mesh */, typename MeshT::EdgeHandle /* _eh */ )
00078   {
00079     return false;
00080   }
00081 
00082 
00084   static bool is_face_selected(const MeshT& _mesh, typename MeshT::FaceHandle _fh)
00085   {
00086     return is_area(_mesh, _fh);
00087   }
00088 };
00089 
00092 template< class MeshT >
00093     struct HandleNodeMod
00094 {
00095 
00097   static inline bool is_handle(const MeshT& _m, typename MeshT::VertexHandle _vh)
00098   { return _m.status(_vh).is_bit_set(HANDLEAREA); }
00099 
00101   static inline bool is_handle(const MeshT& _m, typename MeshT::FaceHandle _fh)
00102   { return _m.status(_fh).is_bit_set(HANDLEAREA); }
00103 
00104 
00106   static bool is_vertex_selected(const MeshT& _mesh, typename MeshT::VertexHandle _vh)
00107   {
00108     if (!is_handle(_mesh, _vh))
00109       return false;
00110 
00111     for (typename MeshT::CVFIter vf_it(_mesh.cvf_iter(_vh)); vf_it; ++vf_it)
00112       if (is_handle(_mesh, vf_it))
00113         return false;
00114 
00115     return true;
00116   }
00117 
00119   static bool is_edge_selected(const MeshT& _mesh, typename MeshT::EdgeHandle _eh)
00120   {
00121     typename MeshT::HalfedgeHandle hh;
00122     typename MeshT::FaceHandle     fh;
00123 
00124     hh = _mesh.halfedge_handle(_eh, 0);
00125     if (!is_handle(_mesh, _mesh.to_vertex_handle(hh))) return false;
00126 
00127     fh = _mesh.face_handle(hh);
00128     if (fh.is_valid() && is_handle(_mesh, fh)) return false;
00129 
00130     hh = _mesh.halfedge_handle(_eh, 1);
00131     if (!is_handle(_mesh, _mesh.to_vertex_handle(hh))) return false;
00132 
00133     fh = _mesh.face_handle(hh);
00134     if (fh.is_valid() && is_handle(_mesh, fh)) return false;
00135 
00136     return true;
00137   }
00138 
00139 
00141   static bool is_face_selected(const MeshT& _mesh, typename MeshT::FaceHandle _fh)
00142   {
00143     return is_handle(_mesh, _fh);
00144   }
00145 };
00146 
00149 template< class MeshT >
00150     struct FeatureNodeMod
00151 {
00152 
00154   static bool is_vertex_selected(const MeshT& _mesh, typename MeshT::VertexHandle _vh)
00155   {
00156     return _mesh.status(_vh).feature();
00157   }
00158 
00160   static bool is_edge_selected(const MeshT& _mesh, typename MeshT::EdgeHandle _eh)
00161   {
00162     return _mesh.status(_eh).feature();
00163   }
00164 
00165 
00167   static bool is_face_selected(const MeshT& _mesh, typename MeshT::FaceHandle _fh)
00168   {
00169     return _mesh.status(_fh).feature();
00170   }
00171 
00172 };
00173 

acg pic Project OpenFlipper, ©  Computer Graphics Group, RWTH Aachen. Documentation generated using doxygen .