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: 8505 $                                                         *
00038  *   $Author: moebius $                                                      *
00039  *   $Date: 2010-02-09 15:24:25 +0100 (Di, 09. Feb 2010) $                   *
00040  *                                                                           *
00041 \*===========================================================================*/
00042 
00043 #ifndef STATUSNODEMODS_HH
00044 #define STATUSNODEMODS_HH
00045 
00046 
00047 
00048 //=============================================================================
00049 //
00050 //  Mods for the Status Nodes
00051 //
00052 //=============================================================================
00053 
00056 template< class MeshT >
00057 struct AreaNodeMod
00058 {
00060   static inline bool is_area(const MeshT& _m, typename MeshT::VertexHandle _vh)
00061   { return _m.status(_vh).is_bit_set(AREA); }
00062 
00064   static inline bool is_area(const MeshT& _m, typename MeshT::FaceHandle _fh)
00065   { return _m.status(_fh).is_bit_set(AREA); }
00066 
00068   static bool is_vertex_selected(const MeshT& _mesh, typename MeshT::VertexHandle _vh)
00069   {
00070     if (_mesh.is_isolated(_vh))
00071       return is_area(_mesh, _vh);
00072     else
00073       return false;
00074   }
00075 
00076 
00078   static bool is_edge_selected(const MeshT& /*_mesh */, typename MeshT::EdgeHandle /* _eh */ )
00079   {
00080     return false;
00081   }
00082 
00083 
00085   static bool is_face_selected(const MeshT& _mesh, typename MeshT::FaceHandle _fh)
00086   {
00087     return is_area(_mesh, _fh);
00088   }
00089 };
00090 
00093 template< class MeshT >
00094     struct HandleNodeMod
00095 {
00096 
00098   static inline bool is_handle(const MeshT& _m, typename MeshT::VertexHandle _vh)
00099   { return _m.status(_vh).is_bit_set(HANDLEAREA); }
00100 
00102   static inline bool is_handle(const MeshT& _m, typename MeshT::FaceHandle _fh)
00103   { return _m.status(_fh).is_bit_set(HANDLEAREA); }
00104 
00105 
00107   static bool is_vertex_selected(const MeshT& _mesh, typename MeshT::VertexHandle _vh)
00108   {
00109     if (!is_handle(_mesh, _vh))
00110       return false;
00111 
00112     for (typename MeshT::CVFIter vf_it(_mesh.cvf_iter(_vh)); vf_it; ++vf_it)
00113       if (is_handle(_mesh, vf_it))
00114         return false;
00115 
00116     return true;
00117   }
00118 
00120   static bool is_edge_selected(const MeshT& _mesh, typename MeshT::EdgeHandle _eh)
00121   {
00122     typename MeshT::HalfedgeHandle hh;
00123     typename MeshT::FaceHandle     fh;
00124 
00125     hh = _mesh.halfedge_handle(_eh, 0);
00126     if (!is_handle(_mesh, _mesh.to_vertex_handle(hh))) return false;
00127 
00128     fh = _mesh.face_handle(hh);
00129     if (fh.is_valid() && is_handle(_mesh, fh)) return false;
00130 
00131     hh = _mesh.halfedge_handle(_eh, 1);
00132     if (!is_handle(_mesh, _mesh.to_vertex_handle(hh))) return false;
00133 
00134     fh = _mesh.face_handle(hh);
00135     if (fh.is_valid() && is_handle(_mesh, fh)) return false;
00136 
00137     return true;
00138   }
00139 
00140 
00142   static bool is_face_selected(const MeshT& _mesh, typename MeshT::FaceHandle _fh)
00143   {
00144     return is_handle(_mesh, _fh);
00145   }
00146 };
00147 
00150 template< class MeshT >
00151     struct FeatureNodeMod
00152 {
00153 
00155   static bool is_vertex_selected(const MeshT& _mesh, typename MeshT::VertexHandle _vh)
00156   {
00157     return _mesh.status(_vh).feature();
00158   }
00159 
00161   static bool is_edge_selected(const MeshT& _mesh, typename MeshT::EdgeHandle _eh)
00162   {
00163     return _mesh.status(_eh).feature();
00164   }
00165 
00166 
00168   static bool is_face_selected(const MeshT& _mesh, typename MeshT::FaceHandle _fh)
00169   {
00170     return _mesh.status(_fh).feature();
00171   }
00172 
00173 };
00174 
00175 #endif
00176 

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