| OpenMesh

- Main Page
- Related Pages
- Modules
- Namespaces
- Classes
- Files

- File List
- File Members

All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Modules Pages
fill_props.hh
1 #ifndef FILL_PROPS_HH
2 #define FILL_PROPS_HH
3
4 #include <OpenMesh/Core/Utils/Property.hh>
5 #include "int2roman.hh"
6
7
8 template <typename Mesh>
9 bool
10 fill_props( Mesh& _m, OpenMesh::VPropHandleT<float> _ph, bool _check=false)
11 {
12 static float a[9] = { 1.1f, 2.2f, 3.3f, 4.4f, 5.5f, 6.6f, 7.7f, 8.8f, 9.9f };
13
14 for(typename Mesh::VertexIter it=_m.vertices_begin();
15 it != _m.vertices_end(); ++it)
16 {
17 const float v = a[it->idx()%9];
18 if ( _check && !(_m.property( _ph, *it ) == v) )
19 return false;
20 else
21 _m.property( _ph, *it ) = v;
22 }
23 return true;
24 }
25
26
27 template <typename Mesh>
28 bool
29 fill_props( Mesh& _m, OpenMesh::EPropHandleT<bool> _ph, bool _check=false )
30 {
31
32 for( typename Mesh::EdgeIter it=_m.edges_begin();
33 it != _m.edges_end(); ++it)
34 {
35 const size_t n = it->idx();
36 const bool v = ((n&(n-1))==0); // true for 0,1,2,4,8,..
37
38 if (_check && _m.property( _ph, *it ) != v)
39 {
40 return false;
41 }
42 else
43 {
44 _m.property( _ph, *it ) = v;
45 }
46 }
47 return true;
48 }
49
50
51
52 template <typename Mesh>
53 bool
54 fill_props(Mesh& _m, OpenMesh::FPropHandleT<std::string> _ph, bool _check=false)
55 {
56
57 for( typename Mesh::FaceIter it=_m.faces_begin();
58 it != _m.faces_end(); ++it)
59 {
60 const int n = (it->idx()) + 1;
61 _m.property( _ph, *it ) = int2roman(n);
62 }
63 return true;
64 }
65
66
67 template <typename Mesh, typename T>
68 bool
69 fill_props( Mesh& _m, OpenMesh::HPropHandleT<T> _ph, bool _check=false)
70 {
71 T v;
72 static float a[9] = { 1.1f, 2.2f, 3.3f, 4.4f, 5.5f, 6.6f, 7.7f, 8.8f, 9.9f };
73 static float b[9] = { 2.2f, 3.3f, 4.4f, 5.5f, 6.6f, 7.7f, 8.8f, 9.9f, 1.1f };
74 static float c[9] = { 3.3f, 4.4f, 5.5f, 6.6f, 7.7f, 8.8f, 9.9f, 1.1f, 2.2f };
75 static float d[9] = { 4.4f, 5.5f, 6.6f, 7.7f, 8.8f, 9.9f, 1.1f, 2.2f, 3.3f };
76
77 for( typename Mesh::HalfedgeIter it=_m.halfedges_begin();
78 it != _m.halfedges_end(); ++it)
79 {
80 const int n = it->idx();
81
82 v = ((n&(n-1))==0);
83 v.vec4fval[0] = a[n%9];
84 v.vec4fval[1] = b[n%9];
85 v.vec4fval[2] = c[n%9];
86 v.vec4fval[3] = d[n%9];
87
88 if ( _check && _m.property( _ph, *it ) != v )
89 return false;
90 else
91 _m.property( _ph, *it ) = v;
92 }
93 return true;
94 }
95
96 template <typename Mesh, typename T>
97 bool
98 fill_props( Mesh& _m, OpenMesh::MPropHandleT<T> _ph, bool _check=false)
99 {
100 for( typename Mesh::FaceIter it=_m.faces_begin(); it != _m.faces_end(); ++it)
101 {
102 const size_t idx = it->idx();
103 if ( _check && _m.property( _ph )[int2roman(idx+1)] != idx )
104 return false;
105 else
106 _m.property( _ph )[int2roman(idx+1)] = idx;
107 }
108 return true;
109 }
110
111
112 #endif
OpenMesh::VPropHandleT< float >
OpenMesh::EPropHandleT
Handle representing an edge property.
Definition: Property.hh:515
OpenMesh::MPropHandleT
Handle representing a mesh property.
Definition: Property.hh:543
OpenMesh::FPropHandleT
Handle representing a face property.
Definition: Property.hh:529
OpenMesh::HPropHandleT
Handle representing a halfedge property.
Definition: Property.hh:501