StatusNodeMods.hh
00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027
00028
00029
00030
00031
00032
00033
00034
00035
00036
00037
00038
00039
00040
00041
00042
00043 #ifndef STATUSNODEMODS_HH
00044 #define STATUSNODEMODS_HH
00045
00046
00047
00048
00049
00050
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& , typename MeshT::EdgeHandle )
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