ConstPerFaceAttributeHandle
This commit is contained in:
parent
7c601cc837
commit
e0ccec2fc8
|
|
@ -1423,8 +1423,9 @@ public:
|
||||||
|
|
||||||
public:
|
public:
|
||||||
|
|
||||||
/*! \brief Check if an handle to a Per-Vertex Attribute is valid
|
/**
|
||||||
*/
|
* @brief Checks if a handle to a Per-Vertex Attribute is valid
|
||||||
|
*/
|
||||||
template <class ATTR_TYPE>
|
template <class ATTR_TYPE>
|
||||||
static
|
static
|
||||||
bool IsValidHandle( const MeshType & m, const typename MeshType::template PerVertexAttributeHandle<ATTR_TYPE> & a){
|
bool IsValidHandle( const MeshType & m, const typename MeshType::template PerVertexAttributeHandle<ATTR_TYPE> & a){
|
||||||
|
|
@ -1434,8 +1435,9 @@ public:
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
/*! \brief Check if a const handle to a Per-Vertex Attribute is valid
|
/**
|
||||||
*/
|
* @brief Checks if a const handle to a Per-Vertex Attribute is valid
|
||||||
|
*/
|
||||||
template <class ATTR_TYPE>
|
template <class ATTR_TYPE>
|
||||||
static
|
static
|
||||||
bool IsValidHandle( const MeshType & m, const typename MeshType::template ConstPerVertexAttributeHandle<ATTR_TYPE> & a){
|
bool IsValidHandle( const MeshType & m, const typename MeshType::template ConstPerVertexAttributeHandle<ATTR_TYPE> & a){
|
||||||
|
|
@ -1501,12 +1503,8 @@ public:
|
||||||
template <class ATTR_TYPE>
|
template <class ATTR_TYPE>
|
||||||
static
|
static
|
||||||
typename MeshType::template ConstPerVertexAttributeHandle<ATTR_TYPE>
|
typename MeshType::template ConstPerVertexAttributeHandle<ATTR_TYPE>
|
||||||
GetConstPerVertexAttribute( const MeshType & m, std::string name = std::string("")){
|
GetPerVertexAttribute( const MeshType & m, std::string name = std::string("")){
|
||||||
typename MeshType::template ConstPerVertexAttributeHandle<ATTR_TYPE> h;
|
return FindPerVertexAttribute<ATTR_TYPE>(m,name);
|
||||||
if(!name.empty()){
|
|
||||||
return FindConstPerVertexAttribute<ATTR_TYPE>(m,name);
|
|
||||||
}
|
|
||||||
return typename MeshType:: template ConstPerVertexAttributeHandle<ATTR_TYPE>(nullptr,0);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/*! \brief Try to retrieve an handle to an attribute with a given name and ATTR_TYPE
|
/*! \brief Try to retrieve an handle to an attribute with a given name and ATTR_TYPE
|
||||||
|
|
@ -1537,23 +1535,26 @@ public:
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Same as the one above, but without modifying the attribute if it is found.
|
* @brief Try to retrieve a const handle to an attribute with a given name
|
||||||
* (A "find" function should never modify the container in which is looking for..)
|
* and ATTR_TYPE, from the given const mesh.
|
||||||
* Input mesh is const.
|
* If not found, an invalid handle will be returned.
|
||||||
|
* Check it with the function IsValidHandle
|
||||||
*/
|
*/
|
||||||
template <class ATTR_TYPE>
|
template <class ATTR_TYPE>
|
||||||
static typename MeshType::template ConstPerVertexAttributeHandle<ATTR_TYPE>
|
static typename MeshType::template ConstPerVertexAttributeHandle<ATTR_TYPE>
|
||||||
FindConstPerVertexAttribute( const MeshType & m, const std::string & name)
|
FindPerVertexAttribute( const MeshType & m, const std::string & name)
|
||||||
{
|
{
|
||||||
assert(!name.empty());
|
if(!name.empty()){
|
||||||
PointerToAttribute h1; h1._name = name;
|
PointerToAttribute h1; h1._name = name;
|
||||||
typename std::set<PointerToAttribute > :: iterator i;
|
typename std::set<PointerToAttribute > :: iterator i;
|
||||||
|
|
||||||
i =m.vert_attr.find(h1);
|
i =m.vert_attr.find(h1);
|
||||||
if(i!=m.vert_attr.end())
|
if(i!=m.vert_attr.end()){
|
||||||
if((*i)._sizeof == sizeof(ATTR_TYPE) ){
|
if((*i)._sizeof == sizeof(ATTR_TYPE) ){
|
||||||
return typename MeshType::template ConstPerVertexAttributeHandle<ATTR_TYPE>((*i)._handle,(*i).n_attr);
|
return typename MeshType::template ConstPerVertexAttributeHandle<ATTR_TYPE>((*i)._handle,(*i).n_attr);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
return typename MeshType:: template ConstPerVertexAttributeHandle<ATTR_TYPE>(nullptr,0);
|
return typename MeshType:: template ConstPerVertexAttributeHandle<ATTR_TYPE>(nullptr,0);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -1568,7 +1569,7 @@ public:
|
||||||
if(!(*i)._name.empty())
|
if(!(*i)._name.empty())
|
||||||
{
|
{
|
||||||
typename MeshType:: template ConstPerVertexAttributeHandle<ATTR_TYPE> hh;
|
typename MeshType:: template ConstPerVertexAttributeHandle<ATTR_TYPE> hh;
|
||||||
hh = Allocator<MeshType>:: template FindConstPerVertexAttribute <ATTR_TYPE>(m,(*i)._name);
|
hh = Allocator<MeshType>:: template FindPerVertexAttribute <ATTR_TYPE>(m,(*i)._name);
|
||||||
if(IsValidHandle<ATTR_TYPE>(m,hh))
|
if(IsValidHandle<ATTR_TYPE>(m,hh))
|
||||||
all.push_back((*i)._name);
|
all.push_back((*i)._name);
|
||||||
}
|
}
|
||||||
|
|
@ -1742,6 +1743,9 @@ public:
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Per Face Attributes
|
/// Per Face Attributes
|
||||||
|
/**
|
||||||
|
* @brief Checks if a handle to a Per-Face attribute is valid
|
||||||
|
*/
|
||||||
template <class ATTR_TYPE>
|
template <class ATTR_TYPE>
|
||||||
static
|
static
|
||||||
bool IsValidHandle( const MeshType & m, const typename MeshType::template PerFaceAttributeHandle<ATTR_TYPE> & a){
|
bool IsValidHandle( const MeshType & m, const typename MeshType::template PerFaceAttributeHandle<ATTR_TYPE> & a){
|
||||||
|
|
@ -1751,6 +1755,18 @@ public:
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief Checks if a const handle to a Per-Face attribute is valid
|
||||||
|
*/
|
||||||
|
template <class ATTR_TYPE>
|
||||||
|
static
|
||||||
|
bool IsValidHandle( const MeshType & m, const typename MeshType::template ConstPerFaceAttributeHandle<ATTR_TYPE> & a){
|
||||||
|
if(a._handle == nullptr) return false;
|
||||||
|
for(AttrIterator i = m.face_attr.begin(); i!=m.face_attr.end();++i)
|
||||||
|
if ( (*i).n_attr == a.n_attr ) return true;
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
template <class ATTR_TYPE>
|
template <class ATTR_TYPE>
|
||||||
static
|
static
|
||||||
typename MeshType::template PerFaceAttributeHandle<ATTR_TYPE>
|
typename MeshType::template PerFaceAttributeHandle<ATTR_TYPE>
|
||||||
|
|
@ -1803,13 +1819,9 @@ public:
|
||||||
*/
|
*/
|
||||||
template <class ATTR_TYPE>
|
template <class ATTR_TYPE>
|
||||||
static
|
static
|
||||||
typename MeshType::template PerFaceAttributeHandle<ATTR_TYPE>
|
typename MeshType::template ConstPerFaceAttributeHandle<ATTR_TYPE>
|
||||||
GetPerFaceAttribute( const MeshType & m, std::string name = std::string("")){
|
GetPerFaceAttribute( const MeshType & m, std::string name = std::string("")){
|
||||||
typename MeshType::template PerFaceAttributeHandle<ATTR_TYPE> h;
|
return FindPerFaceAttribute<ATTR_TYPE>(m,name);
|
||||||
if(!name.empty()){
|
|
||||||
return FindPerFaceAttribute<ATTR_TYPE>(m,name);
|
|
||||||
}
|
|
||||||
return typename MeshType:: template PerFaceAttributeHandle<ATTR_TYPE>(nullptr,0);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
template <class ATTR_TYPE>
|
template <class ATTR_TYPE>
|
||||||
|
|
@ -1823,7 +1835,7 @@ public:
|
||||||
i =m.face_attr.find(h1);
|
i =m.face_attr.find(h1);
|
||||||
if(i!=m.face_attr.end())
|
if(i!=m.face_attr.end())
|
||||||
if((*i)._sizeof == sizeof(ATTR_TYPE) ){
|
if((*i)._sizeof == sizeof(ATTR_TYPE) ){
|
||||||
if( (*i)._padding != 0 ){
|
if( (*i)._padding != 0 ){
|
||||||
PointerToAttribute attr = (*i); // copy the PointerToAttribute
|
PointerToAttribute attr = (*i); // copy the PointerToAttribute
|
||||||
m.face_attr.erase(i); // remove it from the set
|
m.face_attr.erase(i); // remove it from the set
|
||||||
FixPaddedPerFaceAttribute<ATTR_TYPE>(m,attr);
|
FixPaddedPerFaceAttribute<ATTR_TYPE>(m,attr);
|
||||||
|
|
@ -1837,24 +1849,27 @@ public:
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Same as the one above, but without modifying the attribute if it is found.
|
* @brief Try to retrieve a const handle to an attribute with a given name
|
||||||
* (A "find" function should never modify the container in which is looking for..)
|
* and ATTR_TYPE, from the given const mesh.
|
||||||
* Input mesh is const.
|
* If not found, an invalid handle will be returned.
|
||||||
|
* Check it with the function IsValidHandle
|
||||||
*/
|
*/
|
||||||
template <class ATTR_TYPE>
|
template <class ATTR_TYPE>
|
||||||
static
|
static
|
||||||
typename MeshType::template PerFaceAttributeHandle<ATTR_TYPE>
|
typename MeshType::template ConstPerFaceAttributeHandle<ATTR_TYPE>
|
||||||
FindPerFaceAttribute( const MeshType & m, const std::string & name){
|
FindPerFaceAttribute( const MeshType & m, const std::string & name){
|
||||||
assert(!name.empty());
|
if(!name.empty()){
|
||||||
PointerToAttribute h1; h1._name = name;
|
PointerToAttribute h1; h1._name = name;
|
||||||
typename std::set<PointerToAttribute > ::iterator i;
|
typename std::set<PointerToAttribute > ::iterator i;
|
||||||
|
|
||||||
i =m.face_attr.find(h1);
|
i =m.face_attr.find(h1);
|
||||||
if(i!=m.face_attr.end())
|
if(i!=m.face_attr.end()){
|
||||||
if((*i)._sizeof == sizeof(ATTR_TYPE) ){
|
if((*i)._sizeof == sizeof(ATTR_TYPE) ){
|
||||||
return typename MeshType::template PerFaceAttributeHandle<ATTR_TYPE>((*i)._handle,(*i).n_attr);
|
return typename MeshType::template ConstPerFaceAttributeHandle<ATTR_TYPE>((*i)._handle,(*i).n_attr);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
return typename MeshType:: template PerFaceAttributeHandle<ATTR_TYPE>(nullptr,0);
|
}
|
||||||
|
return typename MeshType:: template ConstPerFaceAttributeHandle<ATTR_TYPE>(nullptr,0);
|
||||||
}
|
}
|
||||||
|
|
||||||
template <class ATTR_TYPE>
|
template <class ATTR_TYPE>
|
||||||
|
|
@ -1864,7 +1879,7 @@ public:
|
||||||
for(i = m.face_attr.begin(); i != m.face_attr.end(); ++i )
|
for(i = m.face_attr.begin(); i != m.face_attr.end(); ++i )
|
||||||
if(!(*i)._name.empty())
|
if(!(*i)._name.empty())
|
||||||
{
|
{
|
||||||
typename MeshType:: template PerFaceAttributeHandle<ATTR_TYPE> hh;
|
typename MeshType:: template ConstPerFaceAttributeHandle<ATTR_TYPE> hh;
|
||||||
hh = Allocator<MeshType>:: template FindPerFaceAttribute <ATTR_TYPE>(m,(*i)._name);
|
hh = Allocator<MeshType>:: template FindPerFaceAttribute <ATTR_TYPE>(m,(*i)._name);
|
||||||
if(IsValidHandle<ATTR_TYPE>(m,hh))
|
if(IsValidHandle<ATTR_TYPE>(m,hh))
|
||||||
all.push_back((*i)._name);
|
all.push_back((*i)._name);
|
||||||
|
|
|
||||||
|
|
@ -330,7 +330,6 @@ public:
|
||||||
ConstPerVertexAttributeHandle( const void *ah,const int & n):ConstAttributeHandle<ATTR_TYPE,VertContainer>(ah,n){}
|
ConstPerVertexAttributeHandle( const void *ah,const int & n):ConstAttributeHandle<ATTR_TYPE,VertContainer>(ah,n){}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
template <class ATTR_TYPE>
|
template <class ATTR_TYPE>
|
||||||
class PerFaceAttributeHandle: public AttributeHandle<ATTR_TYPE,FaceContainer>{
|
class PerFaceAttributeHandle: public AttributeHandle<ATTR_TYPE,FaceContainer>{
|
||||||
public:
|
public:
|
||||||
|
|
@ -338,6 +337,13 @@ public:
|
||||||
PerFaceAttributeHandle( void *ah,const int & n):AttributeHandle<ATTR_TYPE,FaceContainer>(ah,n){}
|
PerFaceAttributeHandle( void *ah,const int & n):AttributeHandle<ATTR_TYPE,FaceContainer>(ah,n){}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
template <class ATTR_TYPE>
|
||||||
|
class ConstPerFaceAttributeHandle: public ConstAttributeHandle<ATTR_TYPE,FaceContainer>{
|
||||||
|
public:
|
||||||
|
ConstPerFaceAttributeHandle():ConstAttributeHandle<ATTR_TYPE,FaceContainer>(){}
|
||||||
|
ConstPerFaceAttributeHandle( void *ah,const int & n):ConstAttributeHandle<ATTR_TYPE,FaceContainer>(ah,n){}
|
||||||
|
};
|
||||||
|
|
||||||
template <class ATTR_TYPE>
|
template <class ATTR_TYPE>
|
||||||
class PerEdgeAttributeHandle: public AttributeHandle<ATTR_TYPE,EdgeContainer>{
|
class PerEdgeAttributeHandle: public AttributeHandle<ATTR_TYPE,EdgeContainer>{
|
||||||
public:
|
public:
|
||||||
|
|
@ -345,6 +351,13 @@ public:
|
||||||
PerEdgeAttributeHandle( void *ah,const int & n):AttributeHandle<ATTR_TYPE,EdgeContainer>(ah,n){}
|
PerEdgeAttributeHandle( void *ah,const int & n):AttributeHandle<ATTR_TYPE,EdgeContainer>(ah,n){}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
template <class ATTR_TYPE>
|
||||||
|
class ConstPerEdgeAttributeHandle: public ConstAttributeHandle<ATTR_TYPE,EdgeContainer>{
|
||||||
|
public:
|
||||||
|
ConstPerEdgeAttributeHandle():ConstAttributeHandle<ATTR_TYPE,EdgeContainer>(){}
|
||||||
|
ConstPerEdgeAttributeHandle( void *ah,const int & n):ConstAttributeHandle<ATTR_TYPE,EdgeContainer>(ah,n){}
|
||||||
|
};
|
||||||
|
|
||||||
template <class ATTR_TYPE>
|
template <class ATTR_TYPE>
|
||||||
class PerTetraAttributeHandle : public AttributeHandle<ATTR_TYPE, TetraContainer>
|
class PerTetraAttributeHandle : public AttributeHandle<ATTR_TYPE, TetraContainer>
|
||||||
{
|
{
|
||||||
|
|
@ -353,6 +366,14 @@ public:
|
||||||
PerTetraAttributeHandle(void *ah, const int &n) : AttributeHandle<ATTR_TYPE, TetraContainer>(ah, n) {}
|
PerTetraAttributeHandle(void *ah, const int &n) : AttributeHandle<ATTR_TYPE, TetraContainer>(ah, n) {}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
template <class ATTR_TYPE>
|
||||||
|
class ConstPerTetraAttributeHandle : public ConstAttributeHandle<ATTR_TYPE, TetraContainer>
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
ConstPerTetraAttributeHandle() : ConstAttributeHandle<ATTR_TYPE, TetraContainer>() {}
|
||||||
|
ConstPerTetraAttributeHandle(void *ah, const int &n) : ConstAttributeHandle<ATTR_TYPE, TetraContainer>(ah, n) {}
|
||||||
|
};
|
||||||
|
|
||||||
template <class ATTR_TYPE>
|
template <class ATTR_TYPE>
|
||||||
class PerMeshAttributeHandle{
|
class PerMeshAttributeHandle{
|
||||||
public:
|
public:
|
||||||
|
|
|
||||||
|
|
@ -374,22 +374,22 @@ namespace vcg {
|
||||||
assert(vcg::tri::HasPerVertexAttribute(m,pi.VertAttrNameVec[i]));
|
assert(vcg::tri::HasPerVertexAttribute(m,pi.VertAttrNameVec[i]));
|
||||||
switch (pi.VertDescriptorVec[i].stotype1)
|
switch (pi.VertDescriptorVec[i].stotype1)
|
||||||
{
|
{
|
||||||
case ply::T_FLOAT : thfv[i] = vcg::tri::Allocator<SaveMeshType>::template FindConstPerVertexAttribute<float>(m,pi.VertAttrNameVec[i]); break;
|
case ply::T_FLOAT : thfv[i] = vcg::tri::Allocator<SaveMeshType>::template FindPerVertexAttribute<float>(m,pi.VertAttrNameVec[i]); break;
|
||||||
case ply::T_DOUBLE : thdv[i] = vcg::tri::Allocator<SaveMeshType>::template FindConstPerVertexAttribute<double>(m,pi.VertAttrNameVec[i]); break;
|
case ply::T_DOUBLE : thdv[i] = vcg::tri::Allocator<SaveMeshType>::template FindPerVertexAttribute<double>(m,pi.VertAttrNameVec[i]); break;
|
||||||
case ply::T_INT : thiv[i] = vcg::tri::Allocator<SaveMeshType>::template FindConstPerVertexAttribute<int >(m,pi.VertAttrNameVec[i]); break;
|
case ply::T_INT : thiv[i] = vcg::tri::Allocator<SaveMeshType>::template FindPerVertexAttribute<int >(m,pi.VertAttrNameVec[i]); break;
|
||||||
case ply::T_SHORT : thsv[i] = vcg::tri::Allocator<SaveMeshType>::template FindConstPerVertexAttribute<short >(m,pi.VertAttrNameVec[i]); break;
|
case ply::T_SHORT : thsv[i] = vcg::tri::Allocator<SaveMeshType>::template FindPerVertexAttribute<short >(m,pi.VertAttrNameVec[i]); break;
|
||||||
case ply::T_CHAR : thcv[i] = vcg::tri::Allocator<SaveMeshType>::template FindConstPerVertexAttribute<char>(m,pi.VertAttrNameVec[i]); break;
|
case ply::T_CHAR : thcv[i] = vcg::tri::Allocator<SaveMeshType>::template FindPerVertexAttribute<char>(m,pi.VertAttrNameVec[i]); break;
|
||||||
case ply::T_UCHAR : thuv[i] = vcg::tri::Allocator<SaveMeshType>::template FindConstPerVertexAttribute<unsigned char>(m,pi.VertAttrNameVec[i]); break;
|
case ply::T_UCHAR : thuv[i] = vcg::tri::Allocator<SaveMeshType>::template FindPerVertexAttribute<unsigned char>(m,pi.VertAttrNameVec[i]); break;
|
||||||
default : assert(0);
|
default : assert(0);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
std::vector<typename SaveMeshType:: template PerFaceAttributeHandle<float > > thff(pi.FaceDescriptorVec.size());
|
std::vector<typename SaveMeshType:: template ConstPerFaceAttributeHandle<float > > thff(pi.FaceDescriptorVec.size());
|
||||||
std::vector<typename SaveMeshType:: template PerFaceAttributeHandle<double> > thdf(pi.FaceDescriptorVec.size());
|
std::vector<typename SaveMeshType:: template ConstPerFaceAttributeHandle<double> > thdf(pi.FaceDescriptorVec.size());
|
||||||
std::vector<typename SaveMeshType:: template PerFaceAttributeHandle<int > > thif(pi.FaceDescriptorVec.size());
|
std::vector<typename SaveMeshType:: template ConstPerFaceAttributeHandle<int > > thif(pi.FaceDescriptorVec.size());
|
||||||
std::vector<typename SaveMeshType:: template PerFaceAttributeHandle<short > > thsf(pi.FaceDescriptorVec.size());
|
std::vector<typename SaveMeshType:: template ConstPerFaceAttributeHandle<short > > thsf(pi.FaceDescriptorVec.size());
|
||||||
std::vector<typename SaveMeshType:: template PerFaceAttributeHandle<char > > thcf(pi.FaceDescriptorVec.size());
|
std::vector<typename SaveMeshType:: template ConstPerFaceAttributeHandle<char > > thcf(pi.FaceDescriptorVec.size());
|
||||||
std::vector<typename SaveMeshType:: template PerFaceAttributeHandle<unsigned char> > thuf(pi.FaceDescriptorVec.size());
|
std::vector<typename SaveMeshType:: template ConstPerFaceAttributeHandle<unsigned char> > thuf(pi.FaceDescriptorVec.size());
|
||||||
|
|
||||||
for(size_t i=0;i<pi.FaceDescriptorVec.size();i++)
|
for(size_t i=0;i<pi.FaceDescriptorVec.size();i++)
|
||||||
{
|
{
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue