ConstPerMeshAttributeHandle
This commit is contained in:
parent
94dc161edb
commit
34af1c91bd
|
@ -2121,6 +2121,15 @@ public:
|
|||
return false;
|
||||
}
|
||||
|
||||
template <class ATTR_TYPE>
|
||||
static
|
||||
bool IsValidHandle(const MeshType & m, const typename MeshType::template ConstPerMeshAttributeHandle<ATTR_TYPE> & a){
|
||||
if(a._handle == nullptr) return false;
|
||||
for(AttrIterator i = m.mesh_attr.begin(); i!=m.mesh_attr.end();++i)
|
||||
if ( (*i).n_attr == a.n_attr ) return true;
|
||||
return false;
|
||||
}
|
||||
|
||||
template <class ATTR_TYPE>
|
||||
static
|
||||
typename MeshType::template PerMeshAttributeHandle<ATTR_TYPE>
|
||||
|
@ -2159,6 +2168,13 @@ public:
|
|||
return AddPerMeshAttribute<ATTR_TYPE>(m,name);
|
||||
}
|
||||
|
||||
template <class ATTR_TYPE>
|
||||
static
|
||||
typename MeshType::template ConstPerMeshAttributeHandle<ATTR_TYPE>
|
||||
GetPerMeshAttribute(const MeshType & m, std::string name = std::string("")){
|
||||
return FindPerMeshAttribute<ATTR_TYPE>(m,name);
|
||||
}
|
||||
|
||||
template <class ATTR_TYPE>
|
||||
static
|
||||
typename MeshType::template PerMeshAttributeHandle<ATTR_TYPE>
|
||||
|
@ -2185,6 +2201,24 @@ public:
|
|||
return typename MeshType:: template PerMeshAttributeHandle<ATTR_TYPE>(nullptr,0);
|
||||
}
|
||||
|
||||
template <class ATTR_TYPE>
|
||||
static
|
||||
typename MeshType::template ConstPerMeshAttributeHandle<ATTR_TYPE>
|
||||
FindPerMeshAttribute( const MeshType & m, const std::string & name){
|
||||
if (!name.empty()){
|
||||
PointerToAttribute h1; h1._name = name;
|
||||
typename std::set<PointerToAttribute > ::iterator i;
|
||||
i =m.mesh_attr.find(h1);
|
||||
if(i!=m.mesh_attr.end()){
|
||||
if((*i)._sizeof == sizeof(ATTR_TYPE) ){
|
||||
return typename MeshType::template ConstPerMeshAttributeHandle<ATTR_TYPE>((*i)._handle,(*i).n_attr);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return typename MeshType:: template ConstPerMeshAttributeHandle<ATTR_TYPE>(nullptr,0);
|
||||
}
|
||||
|
||||
template <class ATTR_TYPE>
|
||||
static void GetAllPerMeshAttribute(const MeshType & m, std::vector<std::string> &all){
|
||||
typename std::set<PointerToAttribute > :: iterator i;
|
||||
|
|
|
@ -387,7 +387,18 @@ public:
|
|||
|
||||
Attribute<ATTR_TYPE> * _handle;
|
||||
int n_attr;
|
||||
ATTR_TYPE & operator ()(){ return *((ATTR_TYPE*)((Attribute<ATTR_TYPE> *)_handle)->DataBegin());}
|
||||
ATTR_TYPE & operator ()(){ return *((ATTR_TYPE*) (_handle->DataBegin()));}
|
||||
};
|
||||
|
||||
template <class ATTR_TYPE>
|
||||
class ConstPerMeshAttributeHandle{
|
||||
public:
|
||||
ConstPerMeshAttributeHandle(){_handle=nullptr;}
|
||||
ConstPerMeshAttributeHandle(const void *ah,const int & n):_handle ( (const Attribute<ATTR_TYPE> *)ah ),n_attr(n){}
|
||||
|
||||
const Attribute<ATTR_TYPE> * _handle;
|
||||
int n_attr;
|
||||
const ATTR_TYPE & operator ()(){ return *((const ATTR_TYPE*)(_handle->DataBegin()));}
|
||||
};
|
||||
|
||||
// Some common Handle typedefs to simplify use
|
||||
|
|
Loading…
Reference in New Issue