Main Page | Modules | Namespace List | Class Hierarchy | Class List | File List | Namespace Members | Class Members | File Members | Related Pages

fill_props.hh

00001 #ifndef FILL_PROPS_HH
00002 #define FILL_PROPS_HH
00003 
00004 #include <OpenMesh/Core/Utils/Property.hh>
00005 #include "int2roman.hh"
00006 
00007 
00008 template <typename Mesh>
00009 bool 
00010 fill_props( Mesh& _m, OpenMesh::VPropHandleT<float> _ph, bool _check=false)
00011 {
00012   float  v;
00013   static float a[9] = { 1.1f, 2.2f, 3.3f, 4.4f, 5.5f, 6.6f, 7.7f, 8.8f, 9.9f };
00014 
00015   for(typename Mesh::VertexIter it=_m.vertices_begin(); 
00016       it != _m.vertices_end(); ++it)
00017   {
00018     v = a[it.handle().idx()%9];
00019     if ( _check && !(_m.property( _ph, it ) == v) )
00020       return false;
00021     else  
00022       _m.property( _ph, it ) = v;
00023   }
00024   return true;
00025 }
00026 
00027 
00028 template <typename Mesh>
00029 bool 
00030 fill_props( Mesh& _m, OpenMesh::EPropHandleT<bool> _ph, bool _check=false )
00031 {
00032   size_t n;
00033   bool   v;
00034   for( typename Mesh::EdgeIter it=_m.edges_begin();
00035        it != _m.edges_end(); ++it)
00036   {
00037     n = it.handle().idx();
00038     v = ((n&(n-1))==0); // true for 0,1,2,4,8,..
00039 
00040     if (_check && _m.property( _ph, it ) != v)
00041     {
00042       std::cout << "    eprop_bool: " << n << " -> " 
00043                 << _m.property(_ph, it ) << " != " << v << std::endl;
00044       return false;
00045     }
00046     else
00047     {
00048       _m.property( _ph, it ) = v;
00049       std::cout << "    eprop_bool: " << n << " -> " << v << std::endl;
00050     }
00051   }
00052   return true;
00053 }
00054 
00055 
00056 
00057 template <typename Mesh>
00058 bool 
00059 fill_props(Mesh& _m, OpenMesh::FPropHandleT<std::string> _ph, bool _check=false)
00060 {
00061   int  n;
00062   for( typename Mesh::FaceIter it=_m.faces_begin();
00063        it != _m.faces_end(); ++it)
00064   {
00065     n = it.handle().idx();
00066     _m.property( _ph, it ) = int2roman(++n);
00067   }
00068   return true;
00069 }
00070 
00071 
00072 template <typename Mesh, typename T>
00073 bool 
00074 fill_props( Mesh& _m, OpenMesh::HPropHandleT<T> _ph, bool _check=false)
00075 {
00076   int  n;
00077   T    v;  
00078   static float a[9] = { 1.1f, 2.2f, 3.3f, 4.4f, 5.5f, 6.6f, 7.7f, 8.8f, 9.9f };
00079   static float b[9] = { 2.2f, 3.3f, 4.4f, 5.5f, 6.6f, 7.7f, 8.8f, 9.9f, 1.1f };
00080   static float c[9] = { 3.3f, 4.4f, 5.5f, 6.6f, 7.7f, 8.8f, 9.9f, 1.1f, 2.2f };
00081   static float d[9] = { 4.4f, 5.5f, 6.6f, 7.7f, 8.8f, 9.9f, 1.1f, 2.2f, 3.3f };
00082   static double values[9] = { 0.1, 0.02, 0.003, 0.0004, 0.00005, 0.000006,
00083                               0.0000007, 0.00000008, 0.000000009 };
00084 
00085   for( typename Mesh::HalfedgeIter it=_m.halfedges_begin();
00086        it != _m.halfedges_end(); ++it)
00087   {
00088     n = it.handle().idx();
00089 
00090     v = it.handle().idx()+1; // ival
00091     v = values[n%9];         // dval
00092     v = ((n&(n-1))==0);      // bval
00093     v.vec4fval[0] = a[n%9];
00094     v.vec4fval[1] = b[n%9];
00095     v.vec4fval[2] = c[n%9];
00096     v.vec4fval[3] = d[n%9];
00097 
00098     if ( _check && _m.property( _ph, it ) != v )
00099       return false;
00100     else
00101       _m.property( _ph, it ) = v;
00102   }
00103   return true;
00104 }
00105 
00106 template <typename Mesh, typename T>
00107 bool 
00108 fill_props( Mesh& _m, OpenMesh::MPropHandleT<T> _ph, bool _check=false)
00109 {
00110   size_t idx;
00111   for( typename Mesh::FaceIter it=_m.faces_begin(); it != _m.faces_end(); ++it)
00112   {
00113     idx = it.handle().idx();
00114     if ( _check && _m.property( _ph )[int2roman(idx+1)] != idx )
00115       return false;
00116     else
00117       _m.property( _ph )[int2roman(idx+1)] = idx;
00118   }
00119   return true;
00120 }
00121 
00122 
00123 #endif

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