Developer Documentation
StatusNodeMods.hh
1 /*===========================================================================*\
2 * *
3 * OpenFlipper *
4  * Copyright (c) 2001-2015, RWTH-Aachen University *
5  * Department of Computer Graphics and Multimedia *
6  * All rights reserved. *
7  * www.openflipper.org *
8  * *
9  *---------------------------------------------------------------------------*
10  * This file is part of OpenFlipper. *
11  *---------------------------------------------------------------------------*
12  * *
13  * Redistribution and use in source and binary forms, with or without *
14  * modification, are permitted provided that the following conditions *
15  * are met: *
16  * *
17  * 1. Redistributions of source code must retain the above copyright notice, *
18  * this list of conditions and the following disclaimer. *
19  * *
20  * 2. Redistributions in binary form must reproduce the above copyright *
21  * notice, this list of conditions and the following disclaimer in the *
22  * documentation and/or other materials provided with the distribution. *
23  * *
24  * 3. Neither the name of the copyright holder nor the names of its *
25  * contributors may be used to endorse or promote products derived from *
26  * this software without specific prior written permission. *
27  * *
28  * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS *
29  * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED *
30  * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A *
31  * PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER *
32  * OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, *
33  * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, *
34  * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR *
35  * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF *
36  * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING *
37  * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS *
38  * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. *
39 * *
40 \*===========================================================================*/
41 
42 
43 
44 #ifndef STATUSNODEMODS_HH
45 #define STATUSNODEMODS_HH
46 
47 //=============================================================================
48 //
49 // Mesh Attribute bits for the Status Nodes
50 //
51 //=============================================================================
52 
59 enum StatusBits {
61  AREA = OpenMesh::Attributes::UNUSED << 1,
63  HANDLEAREA = OpenMesh::Attributes::UNUSED << 2
64 };
65 
66 //=============================================================================
67 //
68 // Mods for the Status Nodes
69 //
70 //=============================================================================
71 
74 template< class MeshT >
76 {
78  static inline bool is_area(const MeshT& _m, typename MeshT::VertexHandle _vh)
79  { return _m.status(_vh).is_bit_set(AREA); }
80 
82  static inline bool is_area(const MeshT& _m, typename MeshT::FaceHandle _fh)
83  {
84  for (typename MeshT::ConstFaceVertexIter cfv_it = _m.cfv_iter(_fh); cfv_it.is_valid(); ++cfv_it)
85  if (_m.status(*cfv_it).is_bit_set(AREA))
86  return true;
87 
88  return false;
89  }
90 
92  static bool is_vertex_selected(const MeshT& _mesh, typename MeshT::VertexHandle _vh)
93  {
94  if (_mesh.is_isolated(_vh))
95  return is_area(_mesh, _vh);
96  else
97  return false;
98  }
99 
100 
102  static bool is_edge_selected(const MeshT& /*_mesh */, typename MeshT::EdgeHandle /* _eh */ )
103  {
104  return false;
105  }
106 
107 
109  static bool is_halfedge_selected(const MeshT& /*_mesh */, typename MeshT::HalfedgeHandle /* _eh */ )
110  {
111  return false;
112  }
113 
115  static bool is_face_selected(const MeshT& _mesh, typename MeshT::FaceHandle _fh)
116  {
117  return is_area(_mesh, _fh);
118  }
119 };
120 
123 template< class MeshT >
125 {
126 
128  static inline bool is_handle(const MeshT& _m, typename MeshT::VertexHandle _vh)
129  { return _m.status(_vh).is_bit_set(HANDLEAREA); }
130 
132  static inline bool is_handle(const MeshT& _m, typename MeshT::FaceHandle _fh)
133  {
134  bool isArea = true;
135  for(typename MeshT::ConstFaceVertexIter cfv_it = _m.cfv_iter(_fh); cfv_it.is_valid(); ++cfv_it) {
136  if(!_m.status(*cfv_it).is_bit_set(HANDLEAREA)) {
137  isArea = false;
138  break;
139  }
140  }
141  return isArea;
142  }
143 
144 
146  static bool is_vertex_selected(const MeshT& _mesh, typename MeshT::VertexHandle _vh)
147  {
148  if (!is_handle(_mesh, _vh))
149  return false;
150 
151  for (typename MeshT::CVFIter vf_it(_mesh.cvf_iter(_vh)); vf_it.is_valid(); ++vf_it)
152  if (is_handle(_mesh, *vf_it))
153  return false;
154 
155  return true;
156  }
157 
159  static bool is_edge_selected(const MeshT& _mesh, typename MeshT::EdgeHandle _eh)
160  {
161  typename MeshT::HalfedgeHandle hh;
162  typename MeshT::FaceHandle fh;
163 
164  hh = _mesh.halfedge_handle(_eh, 0);
165  if (!is_handle(_mesh, _mesh.to_vertex_handle(hh))) return false;
166 
167  fh = _mesh.face_handle(hh);
168  if (fh.is_valid() && is_handle(_mesh, fh)) return false;
169 
170  hh = _mesh.halfedge_handle(_eh, 1);
171  if (!is_handle(_mesh, _mesh.to_vertex_handle(hh))) return false;
172 
173  fh = _mesh.face_handle(hh);
174  if (fh.is_valid() && is_handle(_mesh, fh)) return false;
175 
176  return true;
177  }
178 
179 
181  static bool is_halfedge_selected(const MeshT& /*_mesh */, typename MeshT::HalfedgeHandle /* _eh */ )
182  {
183  return false;
184  }
185 
186 
188  static bool is_face_selected(const MeshT& _mesh, typename MeshT::FaceHandle _fh)
189  {
190  return is_handle(_mesh, _fh);
191  }
192 };
193 
196 template< class MeshT >
198 {
199 
201  static bool is_vertex_selected(const MeshT& _mesh, typename MeshT::VertexHandle _vh)
202  {
203  return _mesh.status(_vh).feature();
204  }
205 
207  static bool is_edge_selected(const MeshT& _mesh, typename MeshT::EdgeHandle _eh)
208  {
209  return _mesh.status(_eh).feature();
210  }
211 
212 
214  static bool is_halfedge_selected(const MeshT& _mesh, typename MeshT::HalfedgeHandle _heh)
215  {
216  return _mesh.status(_heh).feature();
217  }
218 
220  static bool is_face_selected(const MeshT& _mesh, typename MeshT::FaceHandle _fh)
221  {
222  return _mesh.status(_fh).feature();
223  }
224 
225 };
226 
227 #endif
228 
static bool is_vertex_selected(const MeshT &_mesh, typename MeshT::VertexHandle _vh)
tell status node if the vertex is marked as modeling area
static bool is_handle(const MeshT &_m, typename MeshT::VertexHandle _vh)
tell status node if the vertex is marked as handle area
static bool is_vertex_selected(const MeshT &_mesh, typename MeshT::VertexHandle _vh)
tell status node if the vertex is marked as handle area
static bool is_face_selected(const MeshT &_mesh, typename MeshT::FaceHandle _fh)
tell status node if the face is marked as feature
static bool is_area(const MeshT &_m, typename MeshT::VertexHandle _vh)
tell status node if the vertex is marked as modeling area
static bool is_edge_selected(const MeshT &, typename MeshT::EdgeHandle)
default to false
static bool is_area(const MeshT &_m, typename MeshT::FaceHandle _fh)
tell status node if the face is marked as modeling area
static bool is_vertex_selected(const MeshT &_mesh, typename MeshT::VertexHandle _vh)
tell status node if the vertex is marked as handle area
static bool is_edge_selected(const MeshT &_mesh, typename MeshT::EdgeHandle _eh)
tell status node if the edge is marked as handle area
static bool is_face_selected(const MeshT &_mesh, typename MeshT::FaceHandle _fh)
tell status node if the face is marked as handle area
static bool is_halfedge_selected(const MeshT &, typename MeshT::HalfedgeHandle)
default to false
static bool is_face_selected(const MeshT &_mesh, typename MeshT::FaceHandle _fh)
tell status node if the face is marked as modeling area
static bool is_edge_selected(const MeshT &_mesh, typename MeshT::EdgeHandle _eh)
tell status node if the edge is marked as handle area
static bool is_halfedge_selected(const MeshT &_mesh, typename MeshT::HalfedgeHandle _heh)
default to false
static bool is_handle(const MeshT &_m, typename MeshT::FaceHandle _fh)
tell status node if the face is marked as handle area
static bool is_halfedge_selected(const MeshT &, typename MeshT::HalfedgeHandle)
default to false