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 * $Revision$ *
45 * $LastChangedBy$ *
46 * $Date$ *
47 * *
48 \*===========================================================================*/
49 
50 #ifndef STATUSNODEMODS_HH
51 #define STATUSNODEMODS_HH
52 
53 //=============================================================================
54 //
55 // Mesh Attribute bits for the Status Nodes
56 //
57 //=============================================================================
58 
65 enum StatusBits {
67  AREA = OpenMesh::Attributes::UNUSED << 1,
69  HANDLEAREA = OpenMesh::Attributes::UNUSED << 2
70 };
71 
72 //=============================================================================
73 //
74 // Mods for the Status Nodes
75 //
76 //=============================================================================
77 
80 template< class MeshT >
82 {
84  static inline bool is_area(const MeshT& _m, typename MeshT::VertexHandle _vh)
85  { return _m.status(_vh).is_bit_set(AREA); }
86 
88  static inline bool is_area(const MeshT& _m, typename MeshT::FaceHandle _fh)
89  {
90  for (typename MeshT::ConstFaceVertexIter cfv_it = _m.cfv_iter(_fh); cfv_it.is_valid(); ++cfv_it)
91  if (_m.status(*cfv_it).is_bit_set(AREA))
92  return true;
93 
94  return false;
95  }
96 
98  static bool is_vertex_selected(const MeshT& _mesh, typename MeshT::VertexHandle _vh)
99  {
100  if (_mesh.is_isolated(_vh))
101  return is_area(_mesh, _vh);
102  else
103  return false;
104  }
105 
106 
108  static bool is_edge_selected(const MeshT& /*_mesh */, typename MeshT::EdgeHandle /* _eh */ )
109  {
110  return false;
111  }
112 
113 
115  static bool is_halfedge_selected(const MeshT& /*_mesh */, typename MeshT::HalfedgeHandle /* _eh */ )
116  {
117  return false;
118  }
119 
121  static bool is_face_selected(const MeshT& _mesh, typename MeshT::FaceHandle _fh)
122  {
123  return is_area(_mesh, _fh);
124  }
125 };
126 
129 template< class MeshT >
131 {
132 
134  static inline bool is_handle(const MeshT& _m, typename MeshT::VertexHandle _vh)
135  { return _m.status(_vh).is_bit_set(HANDLEAREA); }
136 
138  static inline bool is_handle(const MeshT& _m, typename MeshT::FaceHandle _fh)
139  {
140  bool isArea = true;
141  for(typename MeshT::ConstFaceVertexIter cfv_it = _m.cfv_iter(_fh); cfv_it.is_valid(); ++cfv_it) {
142  if(!_m.status(*cfv_it).is_bit_set(HANDLEAREA)) {
143  isArea = false;
144  break;
145  }
146  }
147  return isArea;
148  }
149 
150 
152  static bool is_vertex_selected(const MeshT& _mesh, typename MeshT::VertexHandle _vh)
153  {
154  if (!is_handle(_mesh, _vh))
155  return false;
156 
157  for (typename MeshT::CVFIter vf_it(_mesh.cvf_iter(_vh)); vf_it.is_valid(); ++vf_it)
158  if (is_handle(_mesh, *vf_it))
159  return false;
160 
161  return true;
162  }
163 
165  static bool is_edge_selected(const MeshT& _mesh, typename MeshT::EdgeHandle _eh)
166  {
167  typename MeshT::HalfedgeHandle hh;
168  typename MeshT::FaceHandle fh;
169 
170  hh = _mesh.halfedge_handle(_eh, 0);
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  hh = _mesh.halfedge_handle(_eh, 1);
177  if (!is_handle(_mesh, _mesh.to_vertex_handle(hh))) return false;
178 
179  fh = _mesh.face_handle(hh);
180  if (fh.is_valid() && is_handle(_mesh, fh)) return false;
181 
182  return true;
183  }
184 
185 
187  static bool is_halfedge_selected(const MeshT& /*_mesh */, typename MeshT::HalfedgeHandle /* _eh */ )
188  {
189  return false;
190  }
191 
192 
194  static bool is_face_selected(const MeshT& _mesh, typename MeshT::FaceHandle _fh)
195  {
196  return is_handle(_mesh, _fh);
197  }
198 };
199 
202 template< class MeshT >
204 {
205 
207  static bool is_vertex_selected(const MeshT& _mesh, typename MeshT::VertexHandle _vh)
208  {
209  return _mesh.status(_vh).feature();
210  }
211 
213  static bool is_edge_selected(const MeshT& _mesh, typename MeshT::EdgeHandle _eh)
214  {
215  return _mesh.status(_eh).feature();
216  }
217 
218 
220  static bool is_halfedge_selected(const MeshT& _mesh, typename MeshT::HalfedgeHandle _heh)
221  {
222  return _mesh.status(_heh).feature();
223  }
224 
226  static bool is_face_selected(const MeshT& _mesh, typename MeshT::FaceHandle _fh)
227  {
228  return _mesh.status(_fh).feature();
229  }
230 
231 };
232 
233 #endif
234 
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
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_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_halfedge_selected(const MeshT &_mesh, typename MeshT::HalfedgeHandle _heh)
default to false
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_vertex_selected(const MeshT &_mesh, typename MeshT::VertexHandle _vh)
tell status node if the vertex is marked as handle area
static bool is_halfedge_selected(const MeshT &, typename MeshT::HalfedgeHandle)
default to false
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_face_selected(const MeshT &_mesh, typename MeshT::FaceHandle _fh)
tell status node if the face is marked as feature
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 &, typename MeshT::EdgeHandle)
default to false
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_handle(const MeshT &_m, typename MeshT::VertexHandle _vh)
tell status node if the vertex is marked as handle area
static bool is_area(const MeshT &_m, typename MeshT::FaceHandle _fh)
tell status node if the face is marked as modeling area